From f8ec632ce36fa33aadfb28f515ac585b45118179 Mon Sep 17 00:00:00 2001 From: Joop Kiefte Date: Sun, 20 Sep 2020 09:31:42 +0200 Subject: Add colors --- tris/lines.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'tris/lines.go') 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] } -- cgit v1.2.3-70-g09d2