-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
64 lines (49 loc) · 1.28 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"fmt"
"sudokusolver/pkg/boards"
"sudokusolver/pkg/cells"
"sudokusolver/pkg/solvers"
)
func main() {
fmt.Println("Sudoku solvers")
var easySudoku = []int{
0, 0, 3, 0, 2, 0, 6, 0, 0,
9, 0, 0, 3, 0, 5, 0, 0, 1,
0, 0, 1, 8, 0, 6, 4, 0, 0,
0, 0, 8, 1, 0, 2, 9, 0, 0,
7, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 6, 7, 0, 8, 2, 0, 0,
0, 0, 2, 6, 0, 9, 5, 0, 0,
8, 0, 0, 2, 0, 3, 0, 0, 0,
0, 0, 5, 0, 1, 0, 3, 0, 0,
}
solvedEasyBoard := boards.NewBoard(cells.NewFactory(), easySudoku)
solvers.Solve(solvedEasyBoard)
fmt.Println(solvedEasyBoard.CheckComplete())
echoBoard(solvedEasyBoard)
var hardSudoku = []int{
6, 0, 0, 0, 0, 0, 1, 5, 0,
9, 5, 4, 7, 1, 0, 0, 8, 0,
0, 0, 0, 5, 0, 2, 6, 0, 0,
8, 0, 0, 0, 9, 4, 0, 0, 6,
0, 0, 3, 8, 0, 5, 4, 0, 0,
4, 0, 0, 3, 7, 0, 0, 0, 8,
0, 0, 6, 9, 0, 3, 0, 0, 0,
0, 2, 0, 0, 4, 7, 8, 9, 3,
0, 4, 9, 0, 0, 0, 0, 0, 5,
}
solvedHardBoard := boards.NewBoard(cells.NewFactory(), hardSudoku)
solvers.Solve(solvedHardBoard)
fmt.Println(solvedHardBoard.CheckComplete())
echoBoard(solvedHardBoard)
}
func echoBoard(solvedBoard boards.Board) {
for i := 0; i < boards.CELL_COUNT; i++ {
fmt.Print(solvedBoard.GetCell(i).GetCellValue(), ",")
//fmt.Print( i , ",")
if (i+1)%9 == 0 {
fmt.Print("\n")
}
}
}