Documentation
¶
Index ¶
- func IsValidSudokuString(s string) bool
- type Cell
- type Position
- type SudokuBoard
- func (board *SudokuBoard) FilledCells() int
- func (board *SudokuBoard) FromString(s string)
- func (board *SudokuBoard) Get(position Position) int
- func (board *SudokuBoard) GetRandomPositionWith(validator func(int) bool) *Position
- func (board SudokuBoard) IsEmpty() bool
- func (board SudokuBoard) IsSolved() bool
- func (board SudokuBoard) IsValid() bool
- func (board SudokuBoard) IsValidInput(position Position, value int) bool
- func (board *SudokuBoard) Set(position Position, value int) (err error)
- func (board *SudokuBoard) SetCell(cell Cell) (err error)
- func (board *SudokuBoard) ToString() string
- func (board *SudokuBoard) Unset(position Position)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidSudokuString ¶
Function to check if a Sudoku string is valid.
Types ¶
type Cell ¶
Define the struct for a Sudoku board cell.
func NewCell ¶
Constructor like function to create a new Sudoku cell. Use this when you are sure the cell is valid, will panic otherwise.
func NewCellFromInput ¶
Constructor like function to create a new Sudoku cell from user input. Use this to deal with user input, will return an error if the cell is invalid.
type Position ¶
Define the struct for a Sudoku board position.
func NewPosition ¶
Constructor like function to create a new Sudoku position. Use this when you are sure the position is valid, will panic otherwise.
func NewPositionFromInput ¶
Constructor like function to create a new Sudoku position from user input. Use this to deal with user input, will return an error if the position is invalid.
type SudokuBoard ¶
type SudokuBoard struct {
// contains filtered or unexported fields
}
Define the SudokuBoard struct.
func NewEmptySudokuBoard ¶
func NewEmptySudokuBoard() SudokuBoard
Constructor like function to create a empty Sudoku board.
func (*SudokuBoard) FilledCells ¶
func (board *SudokuBoard) FilledCells() int
Function to get the number of filled cells.
func (*SudokuBoard) FromString ¶
func (board *SudokuBoard) FromString(s string)
Function to build a Sudoku board from a string.
func (*SudokuBoard) Get ¶
func (board *SudokuBoard) Get(position Position) int
Function to get the value of a position.
func (*SudokuBoard) GetRandomPositionWith ¶
func (board *SudokuBoard) GetRandomPositionWith(validator func(int) bool) *Position
Function to get a random position satisfying the value validator.
func (SudokuBoard) IsEmpty ¶
func (board SudokuBoard) IsEmpty() bool
Function to check if the board is empty.
func (SudokuBoard) IsSolved ¶
func (board SudokuBoard) IsSolved() bool
Function to check if the Sudoku board is solved.
func (SudokuBoard) IsValid ¶
func (board SudokuBoard) IsValid() bool
Function to check if the Sudoku board is valid.
func (SudokuBoard) IsValidInput ¶
func (board SudokuBoard) IsValidInput(position Position, value int) bool
Function to check if a value can be placed in a specific position.
func (*SudokuBoard) Set ¶
func (board *SudokuBoard) Set(position Position, value int) (err error)
Function to set the value to a position.
func (*SudokuBoard) SetCell ¶
func (board *SudokuBoard) SetCell(cell Cell) (err error)
Function to set the value of a cell.
func (*SudokuBoard) ToString ¶
func (board *SudokuBoard) ToString() string
Function to print the board as a single string.
func (*SudokuBoard) Unset ¶
func (board *SudokuBoard) Unset(position Position)
Function to unset the value of a position.