const ( ErrorNil = iota ErrorDuplicate ErrorTooManyValues ErrorTooManyAdjacentValues )
func BoardsMatch(t1, t2 *Takuzu, ignoreUndefined bool) (match bool, line, col int)
BoardsMatch compares a Takuzu board to another, optionally ignoring empty cells. Returns true if the two boards match.
func CheckRangeCounts(cells []Cell) (full bool, n0, n1 int)
CheckRangeCounts returns true if all cells of the provided range are defined, as well as the number of 0s and the number of 1s in the range.
func Copy(src, dst *Takuzu) error
Copy copies a Takuzu board to another existing board
func SetSchrodingerLevel(level uint)
SetSchrodingerLevel initializes the "Schrödinger" level (0 means disabled) It must be called before any board generation or reduction.
func SetVerbosityLevel(level int)
SetVerbosityLevel initializes the verbosity level of the resolution routines.
type Cell struct { Defined bool Value int }
Cell is a single cell of a Takuzu game board
func (c *Cell) Set(value int)
Set sets the value of the cell; a value -1 will set the cell as undefined
type Takuzu struct { Size int Board [][]Cell }
Takuzu is a Takuzu game board (Size x Size)
func New(size int) Takuzu
New creates a new Takuzu board
func NewFromString(s string) (*Takuzu, error)
NewFromString creates a new Takuzu board from a string definition
func NewRandomTakuzu(size int, simple bool, wid string, buildBoardTimeout, reduceBoardTimeout time.Duration, minRatio, maxRatio int) (*Takuzu, error)
NewRandomTakuzu creates a new Takuzu board with a given size
func (b Takuzu) CheckColumn(i int) error
CheckColumn returns an error if the column i fails validation
func (b Takuzu) CheckLine(i int) error
CheckLine returns an error if the line i fails validation
func (b Takuzu) Clone() Takuzu
Clone returns a copy of the Takuzu board
func (b Takuzu) DumpBoard()
DumpBoard displays the Takuzu board
func (b Takuzu) DumpString()
DumpString writes the content of the board as a string
func (b Takuzu) FillLineColumn(l, c int)
FillLineColumn add missing 0s or 1s if all 1s or 0s are there. Note: This method can update b.
func (b Takuzu) GetColumn(i int) []Cell
GetColumn returns a slice of cells containing the ith column of the board
func (b Takuzu) GetColumnPointers(i int) []*Cell
GetColumnPointers returns a slice of pointers to the cells of the ith column of the board
func (b Takuzu) GetLine(i int) []Cell
GetLine returns a slice of cells containing the ith line of the board
func (b Takuzu) GetLinePointers(i int) []*Cell
GetLinePointers returns a slice of pointers to the cells of the ith line of the board
func (tak Takuzu) ReduceBoard(trivial bool, wid string, buildBoardTimeout, reduceBoardTimeout time.Duration) (*Takuzu, error)
ReduceBoard randomly removes as many numbers as possible from the takuzu board and returns a pointer to the new board. The initial takuzu might be modified.
func (b Takuzu) Set(l, c, value int)
Set sets the value of a specific cell A value -1 will undefine the cell
func (b Takuzu) ToString() string
ToString converts a takuzu board to its string representation
func (b Takuzu) TrivialHint() (line, col, value int)
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) TrySolveRecurse(allSolutions *[]Takuzu, timeout time.Duration) (*Takuzu, error)
TrySolveRecurse tries to solve the takuzu recursively, using trivial method first and using guesses if it fails.
func (b Takuzu) TrySolveTrivial() (bool, error)
TrySolveTrivial tries to solve the takuzu using a loop over simple methods It returns true if all cells are defined, and an error if the grid breaks the rules.
func (b Takuzu) Validate() (bool, error)
Validate checks a whole board for errors (not completeness) Returns true if all cells are defined.