package tris // Lines counts the number of lines that is completed and returns a Field with them removed func (f Field) Lines() (int, Field) { var n int 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 full(line) { n++ } else { nf = append(nf, line) } } // compress for i := 0; i < 20; i++ { if i < n { f[i] = make([]int, len(f[0])) } else { f[i] = nf[i-n] } } return n, f }