Documentation ¶
Index ¶
- func BitsIndexes(n uint16) []int
- func BoxCoordToGridIndex(box int, pos int) int
- func CoordToBox(r int, c int) int
- func IndexToCoord(i int) (int, int)
- func IsolatedBitIndex(n uint16) (int, bool)
- type Cell
- func (c Cell) GetCandidates() uint16
- func (c *Cell) HasCandidate(n int) bool
- func (c *Cell) HasNoCandidate() bool
- func (c Cell) HasOneCandidate() (int, bool)
- func (c Cell) IsSet() bool
- func (c *Cell) RemoveCandidate(n int)
- func (c *Cell) RemoveCandidateExcept(digits ...int) bool
- func (c *Cell) RemoveCandidateWithFeedback(n int) bool
- func (c *Cell) SetCandidates(cand uint16)
- type DigitsPositionsMasks
- type Grid
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BitsIndexes ¶
Bits indexes return the 0 base index of every '1' in the base 2 representation of n
func BoxCoordToGridIndex ¶
func CoordToBox ¶
CoordToBox turns sudoku grid coordinates into the coresponding block number
func IndexToCoord ¶
IndexToCoord turns an index in [0, 80] to its sudoku grid row , col coordinates in [0, 8]
func IsolatedBitIndex ¶
IsolatedBitIndex checks if a uint16 is composed of only a single 1 (i.e n is a power of 2) and returns either (-1, false) if it isn't otherwise it's base 1 index and true. (log2(n), true)
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
func (Cell) GetCandidates ¶
GetCandidates returns the Cell's candidates
func (*Cell) HasCandidate ¶
HasCandidate checks if the Cell has the candidate {n}
func (*Cell) HasNoCandidate ¶
HasNoCandidates returns true if there is no possible candidate for this Cell (i.e invalid grid)
func (Cell) HasOneCandidate ¶
HasOneCandidate check if a Cell has only one candidate possible and returns it if it exists
func (*Cell) RemoveCandidate ¶
RemoveCandidate removes the candiates {n} from the possible candidates
func (*Cell) RemoveCandidateExcept ¶
RemoveCandidateExcept removes all candidates except the ones listed in the arguments
func (*Cell) RemoveCandidateWithFeedback ¶
RemoveCandidateWithFeedback removes the candiates {n} from the possible candidates returs true if a value was removed, false if the value was already removed
func (*Cell) SetCandidates ¶
SetCandiates forces the candidates values, this only serves testing purposes, do not use
type DigitsPositionsMasks ¶
type Grid ¶
type Grid struct { Grid []Cell Rows [][]*Cell Cols [][]*Cell Boxes [][]*Cell DigitsPositions DigitsPositionsMasks }
func (*Grid) InsertNumberByIndex ¶
func (*Grid) UpdateDigitsPositionMask ¶
func (g *Grid) UpdateDigitsPositionMask()
UpdateDigitsPositionMask creates a map with 3 keys (rows,cols,boxes) each element contains a 2D array of uint16. The first dimension correspond to the set number (row 1, col3...) the second dimension correspond to a sudoku number (base 0) for witch you want the mask in the row ex: row[0][4] = 0b100100100 means that in row 1, the 5 could be in positions 3,6 or 9