Documentation ¶
Index ¶
- func Render(g *Grid) string
- func RenderDiff(g, og *Grid) string
- type Block
- type Grid
- func (g *Grid) ApplyDifficulty(d difficulty.Difficulty)
- func (g *Grid) ApplyPattern(p *pattern.Pattern)
- func (g Grid) Checksum() string
- func (g Grid) Clone() *Grid
- func (g *Grid) CopySubGrid(srcGrid *Grid, srcLoc, dstLoc Location) error
- func (g Grid) Count() int
- func (g Grid) CountToDo() int
- func (g Grid) CountValue(n int) int
- func (g Grid) Done() bool
- func (g Grid) Empty() bool
- func (g Grid) Get(row, col int) int
- func (g Grid) GetMetadata(key string) string
- func (g Grid) HasInColumn(col, n int) bool
- func (g Grid) HasInRow(row, n int) bool
- func (g Grid) IsSet(row, col int) bool
- func (g *Grid) MarshalArray() [][]int
- func (g *Grid) MarshalCSV() string
- func (g Grid) Possibilities(row, col int) *Possibilities
- func (g *Grid) Reset(row, col int)
- func (g *Grid) Set(row, col, n int) bool
- func (g *Grid) SetMetadata(key, val string)
- func (g *Grid) SetRNG(rng *rand.Rand)
- func (g Grid) String() string
- func (g *Grid) SubGrid(row, col int) *SubGrid
- func (g *Grid) SubGrids() SubGrids
- func (g *Grid) UnmarshalArray(arr [][]int) error
- func (g *Grid) UnmarshalCSV(csvString string) error
- func (g *Grid) Validate() (bool, error)
- type Location
- type Option
- type Possibilities
- type SubGrid
- type SubGrids
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderDiff ¶ added in v0.0.2
RenderDiff renders the given Sudoku Grid in a pretty ASCII table and highlights the differences compared to Grid 'og'.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block defines one individual slot in the 9x9 grid.
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid is a 3x3 matrix of Grids - basically a 9x9 matrix of integers.
func (*Grid) ApplyDifficulty ¶
func (g *Grid) ApplyDifficulty(d difficulty.Difficulty)
ApplyDifficulty applies the difficulty level on the current grid.
func (*Grid) ApplyPattern ¶
ApplyPattern applies the pattern on the current grid.
func (*Grid) CopySubGrid ¶
CopySubGrid copies the values from the SubGrid that contains the source Location into the SubGrid that contains the target Location.
func (Grid) CountValue ¶ added in v0.0.2
CountValue returns the number of Blocks that are filled with the given value.
func (Grid) GetMetadata ¶
GetMetadata returns metadata stored against a key.
func (Grid) HasInColumn ¶
HasInColumn returns true if the column 'col' contains the number 'n',
func (*Grid) MarshalArray ¶
MarshalArray returns the Grid in a simple 2-dimensional array.
func (*Grid) MarshalCSV ¶
MarshalCSV returns the Grid in a simple CSV string.
func (Grid) Possibilities ¶
func (g Grid) Possibilities(row, col int) *Possibilities
Possibilities returns the Possibilities for the given block at row 'row' and column 'col'.
func (*Grid) Set ¶
Set sets the number 'n' in the row 'row' and column 'col' if it is a valid value to set there.
func (*Grid) SetMetadata ¶
SetMetadata stores metadata stored against a key.
func (*Grid) UnmarshalArray ¶
UnmarshalArray unmarshals a 2-dimensional array into the Grid.
func (*Grid) UnmarshalCSV ¶
UnmarshalCSV unmarshals a CSV string into the Grid.
type Option ¶
type Option func(g *Grid)
Option helps customize the Grid.
func WithSubGrids ¶
WithSubGrids customizes the way Sub-Grids are defined in the Grid.
type Possibilities ¶
type Possibilities struct {
// contains filtered or unexported fields
}
Possibilities keep track of possible values for a single Block.
func NewPossibilitiesFromMap ¶
func NewPossibilitiesFromMap(data map[int]bool, rng *rand.Rand) *Possibilities
NewPossibilitiesFromMap returns a Possibilities object based on the given map. Key being the number (1-9) and the value being whether it is possible or not.
func (Possibilities) Available ¶
func (p Possibilities) Available() []int
Available returns the available values.
func (Possibilities) AvailableLen ¶
func (p Possibilities) AvailableLen() int
AvailableLen returns the number of available values.
func (Possibilities) AvailableMap ¶ added in v0.0.2
func (p Possibilities) AvailableMap() map[int]bool
AvailableMap returns the available values in a map for quick look-ups.
func (*Possibilities) Get ¶
func (p *Possibilities) Get() int
Get returns the first possible number and takes it out of available numbers list.
func (*Possibilities) ResetAvailable ¶
func (p *Possibilities) ResetAvailable()
ResetAvailable resets the list of available numbers.
type SubGrid ¶
type SubGrid struct { Locations []Location // contains filtered or unexported fields }
SubGrid is a 3x3 matrix of integers.
func (SubGrid) HasLocation ¶
HasLocation returns true if the SubGrid has the given location.