# HG changeset patch # User Mikael Berthe # Date 1473364650 -7200 # Node ID 4ad659431711d88f1ccbf52f0e75370c71f43a83 # Parent 8415b6bd06e91ffe8ddb7b40b439bc714cb9cda2 Add method TrivialHint() diff -r 8415b6bd06e9 -r 4ad659431711 takuzu.go --- a/takuzu.go Thu Sep 08 20:56:07 2016 +0200 +++ b/takuzu.go Thu Sep 08 21:57:30 2016 +0200 @@ -421,6 +421,24 @@ return -1 // dunno } +// TrivialHint returns the coordinates and the value of the first cell that +// can be guessed using trivial methods. +// It returns {-1, -1, -1} if none can be found. +func (b Takuzu) TrivialHint() (line, col, value int) { + for line = 0; line < b.Size; line++ { + for col = 0; col < b.Size; col++ { + if b.Board[line][col].Defined { + continue + } + if value = b.guessPos(line, col); value != -1 { + return + } + } + } + value, line, col = -1, -1, -1 + return +} + // trySolveTrivialPass does 1 pass over the takuzu board and tries to find // values using simple guesses. func (b Takuzu) trySolveTrivialPass() (changed bool) {