generator

package
v0.0.0-...-4415030 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(level int) string

Generate generates a question with unique solution

Types

type Sudoku

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

Sudoku quastion board

func LasVegas

func LasVegas(ctx context.Context, n int) (*Sudoku, error)

LasVegas algorithm generates a Sudoku solution, 99% success rate

func NewSudoku

func NewSudoku(board [9][9]byte) *Sudoku

NewSudoku initial a board

func (*Sudoku) BackTrace

func (s *Sudoku) BackTrace(ctx context.Context, x, y int)

BackTrace use deep first search

func (*Sudoku) CanInsert

func (s *Sudoku) CanInsert(x, y int, inp byte) bool

CanInsert judge whether number inp can be inserted into (x, y)

func (*Sudoku) DigHole

func (s *Sudoku) DigHole(holes int)

DigHole dig holes on board

func (*Sudoku) Insert

func (s *Sudoku) Insert(x, y int, inp byte)

Insert number inp into (x, y)

func (*Sudoku) Output

func (s *Sudoku) Output()

Output the board

func (*Sudoku) Remove

func (s *Sudoku) Remove(x, y int)

Remove number inp from (x, y)

func (*Sudoku) SolveSudoku

func (s *Sudoku) SolveSudoku(ctx context.Context) bool

SolveSudoku accept a 9*9 byte array and solve it

Jump to

Keyboard shortcuts

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