diff options
author | Joop Kiefte <ikojba@gmail.com> | 2020-09-20 09:31:42 +0200 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2020-09-20 09:31:42 +0200 |
commit | f8ec632ce36fa33aadfb28f515ac585b45118179 (patch) | |
tree | 779c0acddc0a1a1d7c730f32ea128d0d83ccc94c /tris/lines.go | |
parent | e238c3df5ead21be7868e649dc405b54793ad4eb (diff) |
Add colors
Diffstat (limited to 'tris/lines.go')
-rw-r--r-- | tris/lines.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tris/lines.go b/tris/lines.go index 7c7026b..37ec35c 100644 --- a/tris/lines.go +++ b/tris/lines.go @@ -2,14 +2,21 @@ package tris // Lines counts the number of lines that is completed and returns a Field with them removed 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 + var nf [][]int + + full := func(line []int) bool { + for _, el := range line { + if el == 0 { + return false + } + } + return true + } // count and collect for _, line := range f { - if line == full { + if full(line) { n++ } else { nf = append(nf, line) @@ -19,7 +26,7 @@ func (f Field) Lines() (int, Field) { // compress for i := 0; i < 20; i++ { if i < n { - f[i] = empty + f[i] = make([]int, len(f[0])) } else { f[i] = nf[i-n] } |