Change internal Solution storage to [][]string (Closes #24)
This commit is contained in:
parent
515034a64e
commit
647476f6d8
@ -23,7 +23,7 @@ type Controller struct {
|
|||||||
// 9th row of the Sudoku puzzle.
|
// 9th row of the Sudoku puzzle.
|
||||||
Row9 string
|
Row9 string
|
||||||
// Slice with all found solutions.
|
// Slice with all found solutions.
|
||||||
Solutions []string
|
Solutions [][]string
|
||||||
// Number of CPUs Go routines are allowed to use.
|
// Number of CPUs Go routines are allowed to use.
|
||||||
NumCPUs int
|
NumCPUs int
|
||||||
// Number of parts the search should be split into.
|
// Number of parts the search should be split into.
|
||||||
|
@ -9,19 +9,13 @@ import (
|
|||||||
func (export *Export) PrintHumanSolutions() {
|
func (export *Export) PrintHumanSolutions() {
|
||||||
for solutionIndex, solution := range export.Controller.Solutions {
|
for solutionIndex, solution := range export.Controller.Solutions {
|
||||||
log.Printf("\nSolution #%d:", solutionIndex+1)
|
log.Printf("\nSolution #%d:", solutionIndex+1)
|
||||||
//fmt.Println(solution)
|
|
||||||
fmt.Println("╔═══════════╗")
|
fmt.Println("╔═══════════╗")
|
||||||
fmt.Println("║" + solution[0:3] + "│" + solution[3:6] + "│" + solution[6:9] + "╢")
|
for rowIndex, row := range solution {
|
||||||
fmt.Println("║" + solution[10:13] + "│" + solution[13:16] + "│" + solution[16:19] + "╢")
|
if rowIndex == 3 || rowIndex == 6 {
|
||||||
fmt.Println("║" + solution[20:23] + "│" + solution[23:26] + "│" + solution[26:29] + "╢")
|
|
||||||
fmt.Println("╟───┼───┼───╢")
|
fmt.Println("╟───┼───┼───╢")
|
||||||
fmt.Println("║" + solution[30:33] + "│" + solution[33:36] + "│" + solution[36:39] + "╢")
|
}
|
||||||
fmt.Println("║" + solution[40:43] + "│" + solution[43:46] + "│" + solution[46:49] + "╢")
|
fmt.Println("║" + row[0:3] + "│" + row[3:6] + "│" + row[6:9] + "╢")
|
||||||
fmt.Println("║" + solution[50:53] + "│" + solution[53:56] + "│" + solution[56:59] + "╢")
|
}
|
||||||
fmt.Println("╟───┼───┼───╢")
|
|
||||||
fmt.Println("║" + solution[60:63] + "│" + solution[63:66] + "│" + solution[66:69] + "╢")
|
|
||||||
fmt.Println("║" + solution[70:73] + "│" + solution[73:76] + "│" + solution[76:79] + "╢")
|
|
||||||
fmt.Println("║" + solution[80:83] + "│" + solution[83:86] + "│" + solution[86:89] + "╢")
|
|
||||||
fmt.Println("╚═══════════╝")
|
fmt.Println("╚═══════════╝")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Prepare a valid solution for storage.
|
// Prepare a valid solution for storage.
|
||||||
func (solver *Solver) renderCombination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) string {
|
func (solver *Solver) renderCombination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) []string {
|
||||||
|
|
||||||
row1s := strconv.Itoa(row1)
|
row1s := strconv.Itoa(row1)
|
||||||
row2s := strconv.Itoa(row2)
|
row2s := strconv.Itoa(row2)
|
||||||
@ -17,5 +17,5 @@ func (solver *Solver) renderCombination(row1 int, row2 int, row3 int, row4 int,
|
|||||||
row8s := strconv.Itoa(row8)
|
row8s := strconv.Itoa(row8)
|
||||||
row9s := strconv.Itoa(row9)
|
row9s := strconv.Itoa(row9)
|
||||||
|
|
||||||
return row1s + "\n" + row2s + "\n" + row3s + "\n" + row4s + "\n" + row5s + "\n" + row6s + "\n" + row7s + "\n" + row8s + "\n" + row9s + "\n"
|
return []string{row1s, row2s, row3s, row4s, row5s, row6s, row7s, row8s, row9s}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user