sudoku

package
v0.0.0-...-5de6322 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoxRule

type BoxRule struct {
	// contains filtered or unexported fields
}

func NewBoxRule

func NewBoxRule(box int) (*BoxRule, error)

NewBoxRule : Create a new BoxRule

func (*BoxRule) Check

func (r *BoxRule) Check(sudoku *Sudoku) (bool, error)

Check : Check if box n rule is broken

func (*BoxRule) GetBox

func (b *BoxRule) GetBox() int

type Cell

type Cell struct {
	Row    int
	Column int
}

type ColumnRule

type ColumnRule struct {
	// contains filtered or unexported fields
}

func NewColumnRule

func NewColumnRule(col int) (*ColumnRule, error)

NewColumnRule : Create a new ColumnRule

func (*ColumnRule) Check

func (r *ColumnRule) Check(sudoku *Sudoku) (bool, error)

Check : Check if column n rule is broken

func (*ColumnRule) GetColumn

func (c *ColumnRule) GetColumn() int

type Corner

type Corner int
const (
	UpperLeftCorner Corner = iota
	UpperRightCorner
	LowerRightCorner
	LowerLeftCorner
)

func (Corner) String

func (c Corner) String() string

type DiagonalRule

type DiagonalRule struct {
	// contains filtered or unexported fields
}

func NewDiagonalRule

func NewDiagonalRule(startingCorner Corner) (*DiagonalRule, error)

NewDiagonalRule : Create a new DiagonalRule

func (*DiagonalRule) Check

func (r *DiagonalRule) Check(sudoku *Sudoku) (bool, error)

Check : Check if column n rule is broken

func (*DiagonalRule) GetStartingCorner

func (d *DiagonalRule) GetStartingCorner() Corner

type RowRule

type RowRule struct {
	// contains filtered or unexported fields
}

func NewRowRule

func NewRowRule(row int) (*RowRule, error)

NewRowRule : Create a new RowRule

func (*RowRule) Check

func (r *RowRule) Check(sudoku *Sudoku) (bool, error)

Check : Check if row n rule is broken

func (*RowRule) GetRow

func (r *RowRule) GetRow() int

type Rule

type Rule interface {
	Check(sudoku *Sudoku) (bool, error)
}

type Sudoku

type Sudoku struct {
	// contains filtered or unexported fields
}

func NewSudoku

func NewSudoku() *Sudoku

NewSudoku : Create a new Sudoku

func (*Sudoku) AddRule

func (s *Sudoku) AddRule(rule Rule)

AddRule : Add a rule to the sudoku rule set

func (*Sudoku) CheckRules

func (s *Sudoku) CheckRules() (bool, error)

CheckRules : Check all rules

func (*Sudoku) GetBoxNotation

func (s *Sudoku) GetBoxNotation(row, col int) (map[int]bool, error)

GetBoxNotation : Get the box notations for the specified cell

func (*Sudoku) GetCellNotation

func (s *Sudoku) GetCellNotation(row, col int) (map[int]bool, error)

GetCellNotation : Get the cell notations for the specified cell

func (*Sudoku) GetGiven

func (s *Sudoku) GetGiven(row, col int) (bool, error)

GetGiven : Gets if the specified row and column is a given value

func (*Sudoku) GetValue

func (s *Sudoku) GetValue(row, col int) (int, error)

GetValue : Gets the value of the cell in the specified row and column

func (*Sudoku) IsFull

func (s *Sudoku) IsFull() (bool, error)

IsFull : Is the sudoku full?

func (*Sudoku) SetGiven

func (s *Sudoku) SetGiven(row, col, value int) error

SetGiven : Sets the specified row and column as a given value

func (*Sudoku) SetSudoku

func (s *Sudoku) SetSudoku(grid [9][9]int) error

SetSudoku : Fills the sudoku grid with the values provided

func (*Sudoku) SetValue

func (s *Sudoku) SetValue(row, col, value int) error

SetValue : Sets the value of the cell in the specified row and column to the specified value

func (*Sudoku) ToggleBoxNotation

func (s *Sudoku) ToggleBoxNotation(row, col, value int) error

ToggleBoxNotation : Toggle the box notation for the specified cell for value

func (*Sudoku) ToggleCellNotation

func (s *Sudoku) ToggleCellNotation(row, col, value int) error

ToggleCellNotation : Toggle the cell notation for the specified cell for value

type SumRule

type SumRule struct {
	// contains filtered or unexported fields
}

func NewSumRule

func NewSumRule(sum int, cells []Cell, digitsCanRepeat bool, backgroundColor color.Color) (*SumRule, error)

NewSumRule : Create a new SumRule

func (*SumRule) Check

func (s *SumRule) Check(sudoku *Sudoku) (bool, error)

func (*SumRule) GetBackgroundColor

func (s *SumRule) GetBackgroundColor() color.Color

func (*SumRule) GetCells

func (s *SumRule) GetCells() []Cell

func (*SumRule) GetDigitsCanRepeat

func (s *SumRule) GetDigitsCanRepeat() bool

func (*SumRule) GetSum

func (s *SumRule) GetSum() int

type ThermoRule

type ThermoRule struct {
	// contains filtered or unexported fields
}

func NewThermoRule

func NewThermoRule(cells []Cell, increasing, strict bool, backgroundColor color.Color, thermoColor color.Color) (*ThermoRule, error)

NewThermoRule : Create a new ThermoRule

func (*ThermoRule) Check

func (t *ThermoRule) Check(sudoku *Sudoku) (bool, error)

func (*ThermoRule) GetBackgroundColor

func (t *ThermoRule) GetBackgroundColor() color.Color

func (*ThermoRule) GetCells

func (t *ThermoRule) GetCells() []Cell

func (*ThermoRule) GetIncreasing

func (t *ThermoRule) GetIncreasing() bool

func (*ThermoRule) GetStrict

func (t *ThermoRule) GetStrict() bool

func (*ThermoRule) GetThermoColor

func (t *ThermoRule) GetThermoColor() color.Color

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL