sudoku

package
v0.0.0-...-b456ea2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

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

func (*Cell) AllPeers

func (c *Cell) AllPeers() utils.Set[*Cell]

TODO - potential performance optimization - precalculate this for all cells when grid is created

func (*Cell) String

func (c *Cell) String() string

type Grid

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

func EmptyGrid

func EmptyGrid(baseSize int) Grid

func LoadGridsFromFile

func LoadGridsFromFile(filename string) ([]Grid, error)

func ParseSingleGrid

func ParseSingleGrid(str string) Grid

public for testing purposes, and because a pure parsing function is useful to have TODO - potentially move functions for loading from a file into a separate package?

func SolveWithBacktracking

func SolveWithBacktracking(grid Grid) Grid

public entrypoint, validating input and wrapping attemptBacktrackingSolve()

func SolveWithBasicStrategies

func SolveWithBasicStrategies(grid Grid) Grid

func (*Grid) IsCompletelyFilled

func (g *Grid) IsCompletelyFilled() bool

func (*Grid) IsValidSolution

func (g *Grid) IsValidSolution() bool

checks if each row, column, and box has exactly one of each digit/element only checks completely filled-out grids; if a grid has any empty cells, this returns false does *not* check if a grid matches a specific challenge (i.e. whether it matches the givens from the challenge)

func (*Grid) String

func (g *Grid) String() string

type Puzzle

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

TODO - not sure if I want to export the Puzzle type It's currently exported because gopls won't allow renaming it to "puzzle" due to potentially shadowing parameter names this might be a gopls bug - see https://github.com/golang/go/issues/66150

Jump to

Keyboard shortcuts

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