Beispiel #1
0
func Benchmark_slowSolveBasic(b *testing.B) {
	e := puzzle.New(board.Basic())
	m := puzzle.New(board.Medium())
	h := puzzle.New(board.Hard())
	for n := 0; n < b.N; n++ {
		e.SlowSolve()
		m.SlowSolve()
		h.SlowSolve()
	}
}
Beispiel #2
0
func Test_puzzleSetUp(t *testing.T) {
	input := board.Basic()
	newBoard := puzzle.New(input)
	b, _, _ := newBoard.Display()
	if b != board.Basic() {
		fmt.Println(b)
		t.Error("should equal: ", board.Basic())
	}
}
Beispiel #3
0
func Test_slowSolve(t *testing.T) {
	input := board.Basic()
	newBoard := puzzle.New(input)
	newBoard.Solve()
	b, _, _ := newBoard.Display()
	if b != board.Solved() {
		fmt.Println(b)
		t.Error("should equal solved board: ", board.Solved())
	}
}
Beispiel #4
0
func main() {
	i := board.Basic()
	sudoku := puzzle.New(i)
	sudoku.Grade()
	err := sudoku.SlowSolve()
	board, status, dif := sudoku.Display()
	if !err {
		fmt.Println(board, status, dif)
	}
}
Beispiel #5
0
func Test_validate(t *testing.T) {
	input := board.Basic()
	// import standard input
	newBoard := puzzle.New(input)
	newBoard.Solve()
	v := newBoard.Validate()
	if !v {
		fmt.Println(v)
		t.Error("should equal true")
	}
	// import unsolvable input
	input = board.Broken()
	newBoard.FillPuzzle(input)
	newBoard.Solve()
	v = newBoard.Validate()
	if v {
		fmt.Println(v)
		t.Error("should equal false")
	}
}
Beispiel #6
0
func parse(j string) puzzle.Puzzle {
	board := []byte(j)
	var b [9][9]int
	json.Unmarshal(board, &b)
	return puzzle.New(b)
}