takuzu.go
changeset 4 4ad659431711
parent 3 8415b6bd06e9
child 6 110d38ae22cd
equal deleted inserted replaced
3:8415b6bd06e9 4:4ad659431711
   417 	if bx.CheckLine(l) != nil || bx.CheckColumn(c) != nil {
   417 	if bx.CheckLine(l) != nil || bx.CheckColumn(c) != nil {
   418 		return 0
   418 		return 0
   419 	}
   419 	}
   420 
   420 
   421 	return -1 // dunno
   421 	return -1 // dunno
       
   422 }
       
   423 
       
   424 // TrivialHint returns the coordinates and the value of the first cell that
       
   425 // can be guessed using trivial methods.
       
   426 // It returns {-1, -1, -1} if none can be found.
       
   427 func (b Takuzu) TrivialHint() (line, col, value int) {
       
   428 	for line = 0; line < b.Size; line++ {
       
   429 		for col = 0; col < b.Size; col++ {
       
   430 			if b.Board[line][col].Defined {
       
   431 				continue
       
   432 			}
       
   433 			if value = b.guessPos(line, col); value != -1 {
       
   434 				return
       
   435 			}
       
   436 		}
       
   437 	}
       
   438 	value, line, col = -1, -1, -1
       
   439 	return
   422 }
   440 }
   423 
   441 
   424 // trySolveTrivialPass does 1 pass over the takuzu board and tries to find
   442 // trySolveTrivialPass does 1 pass over the takuzu board and tries to find
   425 // values using simple guesses.
   443 // values using simple guesses.
   426 func (b Takuzu) trySolveTrivialPass() (changed bool) {
   444 func (b Takuzu) trySolveTrivialPass() (changed bool) {