diff options
Diffstat (limited to 'tris/lines.go')
-rw-r--r-- | tris/lines.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tris/lines.go b/tris/lines.go new file mode 100644 index 0000000..5cb6981 --- /dev/null +++ b/tris/lines.go @@ -0,0 +1,27 @@ +package tris + +func (f Field) Lines() (int, Field) { + full := [10]bool{true, true, true, true, true, true, true, true, true, true} + empty := [10]bool{false, false, false, false, false, false, false, false, false, false} + var n int + var nf [][10]bool + + // count and collect + for _, line := range f { + if line == full { + n++ + } else { + nf = append(nf, line) + } + } + + // compress + for i := 0; i < 20; i++ { + if i < n { + f[i] = empty + } else { + f[i] = nf[i-n] + } + } + return n, f +} |