1 package sudoku 2 3 // Unique represents a section of data where each cell needs to be different 4 type Unique []int 5 6 // Constrain implements the Constraint interface 7 func (u Unique) Constrain(s *Sudoku, pos int, marked []bool) bool { 8 if slicePos([]int(u), pos) == -1 { 9 return true 10 } 11 myMark := make([]int, 0, len(u)) 12 for _, p := range u { 13 if mp := s.Pos(p); mp != 0 { 14 if slicePos(myMark, mp) != -1 { 15 return false 16 } 17 myMark = append(myMark, mp) 18 marked[mp] = true 19 } 20 } 21 return true 22 }