sudoku

package module
v0.0.0-...-e54bf69 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

README

A Sudoku puzzle solver

An implementation based on logic.

Work in progress.

Usage example

See examples/solve1/main.go and test cases

CI

Code coverage: codecov.io

Documentation

Overview

Package sudoku - generated by fungen; DO NOT EDIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintGrid

func PrintGrid(grid string) error

Types

type Cell

type Cell struct {
	Value int8
	Pos   Pos
}

type CellList

type CellList []Cell

CellList is the type for a list that holds members of type Cell

func (CellList) All

func (l CellList) All(f func(Cell) bool) bool

All is a method on CellList that returns true if all the members of the list satisfy a function or if the list is empty.

func (CellList) Any

func (l CellList) Any(f func(Cell) bool) bool

Any is a method on CellList that returns true if at least one member of the list satisfies a function. It returns false if the list is empty.

func (CellList) Drop

func (l CellList) Drop(n int) CellList

Drop is a method on CellList that takes an integer n and returns all but the first n elements of the original list. If the list contains fewer than n elements then an empty list is returned.

func (CellList) DropWhile

func (l CellList) DropWhile(f func(Cell) bool) CellList

DropWhile is a method on CellList that takes a function of type Cell -> bool and returns a list of type CellList which excludes the first members from the original list for which the function returned true

func (CellList) Each

func (l CellList) Each(f func(Cell)) CellList

Each is a method on CellList that takes a function of type Cell -> void and applies the function to each member of the list and then returns the original list.

func (CellList) EachI

func (l CellList) EachI(f func(int, Cell)) CellList

EachI is a method on CellList that takes a function of type (int, Cell) -> void and applies the function to each member of the list and then returns the original list. The int parameter to the function is the index of the element.

func (CellList) Filter

func (l CellList) Filter(f func(Cell) bool) CellList

Filter is a method on CellList that takes a function of type Cell -> bool returns a list of type CellList which contains all members from the original list for which the function returned true

func (CellList) FilterMapInt

func (l CellList) FilterMapInt(fMap func(Cell) int, fFilters ...func(Cell) bool) intList

FilterMapInt is a method on CellList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (CellList) FilterMapInt8

func (l CellList) FilterMapInt8(fMap func(Cell) int8, fFilters ...func(Cell) bool) int8List

FilterMapInt8 is a method on CellList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (CellList) FilterMapNumCount

func (l CellList) FilterMapNumCount(fMap func(Cell) numCount, fFilters ...func(Cell) bool) numCountList

FilterMapNumCount is a method on CellList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (CellList) FilterMapPos

func (l CellList) FilterMapPos(fMap func(Cell) Pos, fFilters ...func(Cell) bool) PosList

FilterMapPos is a method on CellList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (CellList) Map

func (l CellList) Map(f func(Cell) Cell) CellList

Map is a method on CellList that takes a function of type Cell -> Cell and applies it to every member of CellList

func (CellList) MapInt

func (l CellList) MapInt(f func(Cell) int) intList

MapInt is a method on CellList that takes a function of type Cell -> int and applies it to every member of CellList

func (CellList) MapInt8

func (l CellList) MapInt8(f func(Cell) int8) int8List

MapInt8 is a method on CellList that takes a function of type Cell -> int8 and applies it to every member of CellList

func (CellList) MapNumCount

func (l CellList) MapNumCount(f func(Cell) numCount) numCountList

MapNumCount is a method on CellList that takes a function of type Cell -> numCount and applies it to every member of CellList

func (CellList) MapPos

func (l CellList) MapPos(f func(Cell) Pos) PosList

MapPos is a method on CellList that takes a function of type Cell -> Pos and applies it to every member of CellList

func (CellList) PFilter

func (l CellList) PFilter(f func(Cell) bool) CellList

PFilter is similar to the Filter method except that the filter is applied to all the elements in parallel. The order of resulting elements cannot be guaranteed.

func (CellList) PFilterMapInt

func (l CellList) PFilterMapInt(fMap func(Cell) int, fFilters ...func(Cell) bool) intList

PFilterMapInt is similar to FilterMapInt except that it executes the method on each member in parallel.

func (CellList) PFilterMapInt8

func (l CellList) PFilterMapInt8(fMap func(Cell) int8, fFilters ...func(Cell) bool) int8List

PFilterMapInt8 is similar to FilterMapInt8 except that it executes the method on each member in parallel.

func (CellList) PFilterMapNumCount

func (l CellList) PFilterMapNumCount(fMap func(Cell) numCount, fFilters ...func(Cell) bool) numCountList

PFilterMapNumCount is similar to FilterMapNumCount except that it executes the method on each member in parallel.

func (CellList) PFilterMapPos

func (l CellList) PFilterMapPos(fMap func(Cell) Pos, fFilters ...func(Cell) bool) PosList

PFilterMapPos is similar to FilterMapPos except that it executes the method on each member in parallel.

func (CellList) PMap

func (l CellList) PMap(f func(Cell) Cell) CellList

PMap is similar to Map except that it executes the function on each member in parallel.

func (CellList) PMapInt

func (l CellList) PMapInt(f func(Cell) int) intList

PMapInt is similar to MapInt except that it executes the function on each member in parallel.

func (CellList) PMapInt8

func (l CellList) PMapInt8(f func(Cell) int8) int8List

PMapInt8 is similar to MapInt8 except that it executes the function on each member in parallel.

func (CellList) PMapNumCount

func (l CellList) PMapNumCount(f func(Cell) numCount) numCountList

PMapNumCount is similar to MapNumCount except that it executes the function on each member in parallel.

func (CellList) PMapPos

func (l CellList) PMapPos(f func(Cell) Pos) PosList

PMapPos is similar to MapPos except that it executes the function on each member in parallel.

func (CellList) Reduce

func (l CellList) Reduce(t1 Cell, f func(Cell, Cell) Cell) Cell

Reduce is a method on CellList that takes a function of type (Cell, Cell) -> Cell and returns a Cell which is the result of applying the function to all members of the original list starting from the first member

func (CellList) ReduceRight

func (l CellList) ReduceRight(t1 Cell, f func(Cell, Cell) Cell) Cell

ReduceRight is a method on CellList that takes a function of type (Cell, Cell) -> Cell and returns a Cell which is the result of applying the function to all members of the original list starting from the last member

func (CellList) Take

func (l CellList) Take(n int) CellList

Take is a method on CellList that takes an integer n and returns the first n elements of the original list. If the list contains fewer than n elements then the entire list is returned.

func (CellList) TakeWhile

func (l CellList) TakeWhile(f func(Cell) bool) CellList

TakeWhile is a method on CellList that takes a function of type Cell -> bool and returns a list of type CellList which includes only the first members from the original list for which the function returned true

type DefaultLogger

type DefaultLogger struct {
}

func (DefaultLogger) Eliminated

func (l DefaultLogger) Eliminated(strategy string, cells ...Cell)

func (DefaultLogger) Solved

func (l DefaultLogger) Solved(strategy string, cells ...Cell)

type Logger

type Logger interface {
	Eliminated(strategy string, cell ...Cell)
	Solved(strategy string, cell ...Cell)
}

type Pos

type Pos struct {
	Row    int8
	Column int8
	Box    int8
}

type PosList

type PosList []Pos

PosList is the type for a list that holds members of type Pos

func (PosList) All

func (l PosList) All(f func(Pos) bool) bool

All is a method on PosList that returns true if all the members of the list satisfy a function or if the list is empty.

func (PosList) Any

func (l PosList) Any(f func(Pos) bool) bool

Any is a method on PosList that returns true if at least one member of the list satisfies a function. It returns false if the list is empty.

func (PosList) Drop

func (l PosList) Drop(n int) PosList

Drop is a method on PosList that takes an integer n and returns all but the first n elements of the original list. If the list contains fewer than n elements then an empty list is returned.

func (PosList) DropWhile

func (l PosList) DropWhile(f func(Pos) bool) PosList

DropWhile is a method on PosList that takes a function of type Pos -> bool and returns a list of type PosList which excludes the first members from the original list for which the function returned true

func (PosList) Each

func (l PosList) Each(f func(Pos)) PosList

Each is a method on PosList that takes a function of type Pos -> void and applies the function to each member of the list and then returns the original list.

func (PosList) EachI

func (l PosList) EachI(f func(int, Pos)) PosList

EachI is a method on PosList that takes a function of type (int, Pos) -> void and applies the function to each member of the list and then returns the original list. The int parameter to the function is the index of the element.

func (PosList) Filter

func (l PosList) Filter(f func(Pos) bool) PosList

Filter is a method on PosList that takes a function of type Pos -> bool returns a list of type PosList which contains all members from the original list for which the function returned true

func (PosList) FilterMapCell

func (l PosList) FilterMapCell(fMap func(Pos) Cell, fFilters ...func(Pos) bool) CellList

FilterMapCell is a method on PosList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (PosList) FilterMapInt

func (l PosList) FilterMapInt(fMap func(Pos) int, fFilters ...func(Pos) bool) intList

FilterMapInt is a method on PosList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (PosList) FilterMapInt8

func (l PosList) FilterMapInt8(fMap func(Pos) int8, fFilters ...func(Pos) bool) int8List

FilterMapInt8 is a method on PosList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (PosList) FilterMapNumCount

func (l PosList) FilterMapNumCount(fMap func(Pos) numCount, fFilters ...func(Pos) bool) numCountList

FilterMapNumCount is a method on PosList that applies the filter(s) and map to the list members in a single loop and returns the resulting list.

func (PosList) Map

func (l PosList) Map(f func(Pos) Pos) PosList

Map is a method on PosList that takes a function of type Pos -> Pos and applies it to every member of PosList

func (PosList) MapCell

func (l PosList) MapCell(f func(Pos) Cell) CellList

MapCell is a method on PosList that takes a function of type Pos -> Cell and applies it to every member of PosList

func (PosList) MapInt

func (l PosList) MapInt(f func(Pos) int) intList

MapInt is a method on PosList that takes a function of type Pos -> int and applies it to every member of PosList

func (PosList) MapInt8

func (l PosList) MapInt8(f func(Pos) int8) int8List

MapInt8 is a method on PosList that takes a function of type Pos -> int8 and applies it to every member of PosList

func (PosList) MapNumCount

func (l PosList) MapNumCount(f func(Pos) numCount) numCountList

MapNumCount is a method on PosList that takes a function of type Pos -> numCount and applies it to every member of PosList

func (PosList) PFilter

func (l PosList) PFilter(f func(Pos) bool) PosList

PFilter is similar to the Filter method except that the filter is applied to all the elements in parallel. The order of resulting elements cannot be guaranteed.

func (PosList) PFilterMapCell

func (l PosList) PFilterMapCell(fMap func(Pos) Cell, fFilters ...func(Pos) bool) CellList

PFilterMapCell is similar to FilterMapCell except that it executes the method on each member in parallel.

func (PosList) PFilterMapInt

func (l PosList) PFilterMapInt(fMap func(Pos) int, fFilters ...func(Pos) bool) intList

PFilterMapInt is similar to FilterMapInt except that it executes the method on each member in parallel.

func (PosList) PFilterMapInt8

func (l PosList) PFilterMapInt8(fMap func(Pos) int8, fFilters ...func(Pos) bool) int8List

PFilterMapInt8 is similar to FilterMapInt8 except that it executes the method on each member in parallel.

func (PosList) PFilterMapNumCount

func (l PosList) PFilterMapNumCount(fMap func(Pos) numCount, fFilters ...func(Pos) bool) numCountList

PFilterMapNumCount is similar to FilterMapNumCount except that it executes the method on each member in parallel.

func (PosList) PMap

func (l PosList) PMap(f func(Pos) Pos) PosList

PMap is similar to Map except that it executes the function on each member in parallel.

func (PosList) PMapCell

func (l PosList) PMapCell(f func(Pos) Cell) CellList

PMapCell is similar to MapCell except that it executes the function on each member in parallel.

func (PosList) PMapInt

func (l PosList) PMapInt(f func(Pos) int) intList

PMapInt is similar to MapInt except that it executes the function on each member in parallel.

func (PosList) PMapInt8

func (l PosList) PMapInt8(f func(Pos) int8) int8List

PMapInt8 is similar to MapInt8 except that it executes the function on each member in parallel.

func (PosList) PMapNumCount

func (l PosList) PMapNumCount(f func(Pos) numCount) numCountList

PMapNumCount is similar to MapNumCount except that it executes the function on each member in parallel.

func (PosList) Reduce

func (l PosList) Reduce(t1 Pos, f func(Pos, Pos) Pos) Pos

Reduce is a method on PosList that takes a function of type (Pos, Pos) -> Pos and returns a Pos which is the result of applying the function to all members of the original list starting from the first member

func (PosList) ReduceRight

func (l PosList) ReduceRight(t1 Pos, f func(Pos, Pos) Pos) Pos

ReduceRight is a method on PosList that takes a function of type (Pos, Pos) -> Pos and returns a Pos which is the result of applying the function to all members of the original list starting from the last member

func (PosList) Take

func (l PosList) Take(n int) PosList

Take is a method on PosList that takes an integer n and returns the first n elements of the original list. If the list contains fewer than n elements then the entire list is returned.

func (PosList) TakeWhile

func (l PosList) TakeWhile(f func(Pos) bool) PosList

TakeWhile is a method on PosList that takes a function of type Pos -> bool and returns a list of type PosList which includes only the first members from the original list for which the function returned true

type Sudoku

type Sudoku struct {
	Solved     CellList
	Candidates CellList
	// contains filtered or unexported fields
}

func NewSudoku

func NewSudoku(grid string) (*Sudoku, error)

func (*Sudoku) EnableLogging

func (s *Sudoku) EnableLogging(state bool)

func (Sudoku) GetGridString

func (s Sudoku) GetGridString() string

func (Sudoku) PrintGrid

func (s Sudoku) PrintGrid()

func (*Sudoku) Solve

func (s *Sudoku) Solve() bool

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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