|
|
@ -28,10 +28,10 @@ func (solver *Solver) PopulateBlocks() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// The actual function that finds the blocks matching the partial blocks.
|
|
|
|
// The actual function that finds the blocks matching the partial blocks.
|
|
|
|
func (solver *Solver) findBlocks(row *string, rows *[]int) {
|
|
|
|
func (solver *Solver) findBlocks(row *string, rows *[]string) {
|
|
|
|
// Declare selection
|
|
|
|
// Declare selection
|
|
|
|
var selection []int
|
|
|
|
var selection []string
|
|
|
|
var currBlocks []int
|
|
|
|
var currBlocks []string
|
|
|
|
funcRow := *row
|
|
|
|
funcRow := *row
|
|
|
|
|
|
|
|
|
|
|
|
for letter := range funcRow {
|
|
|
|
for letter := range funcRow {
|
|
|
@ -45,14 +45,14 @@ func (solver *Solver) findBlocks(row *string, rows *[]int) {
|
|
|
|
|
|
|
|
|
|
|
|
for _, block := range currBlocks {
|
|
|
|
for _, block := range currBlocks {
|
|
|
|
|
|
|
|
|
|
|
|
currRow := strconv.Itoa(block)
|
|
|
|
currRow := block
|
|
|
|
|
|
|
|
|
|
|
|
if funcRow[letter] == currRow[letter] {
|
|
|
|
if funcRow[letter] == currRow[letter] {
|
|
|
|
foundRow, _ := strconv.Atoi(currRow)
|
|
|
|
foundRow := currRow
|
|
|
|
selection = append(selection, foundRow)
|
|
|
|
selection = append(selection, foundRow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if funcRow[letter] == '0' {
|
|
|
|
if funcRow[letter] == '0' {
|
|
|
|
foundRow, _ := strconv.Atoi(currRow)
|
|
|
|
foundRow := currRow
|
|
|
|
selection = append(selection, foundRow)
|
|
|
|
selection = append(selection, foundRow)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -92,7 +92,7 @@ func (solver *Solver) validator(rows1Index int, rows2Index int, rows3Index int,
|
|
|
|
solver.counter.Add(1)
|
|
|
|
solver.counter.Add(1)
|
|
|
|
|
|
|
|
|
|
|
|
if solver.validateCombination(solver.row1s[rows1Index], solver.row2s[rows2Index], solver.row3s[rows3Index], solver.row4s[rows4Index], solver.row5s[rows5Index], solver.row6s[rows6Index], solver.row7s[rows7Index], solver.row8s[rows8Index], solver.row9s[rows9Index]) {
|
|
|
|
if solver.validateCombination(solver.row1s[rows1Index], solver.row2s[rows2Index], solver.row3s[rows3Index], solver.row4s[rows4Index], solver.row5s[rows5Index], solver.row6s[rows6Index], solver.row7s[rows7Index], solver.row8s[rows8Index], solver.row9s[rows9Index]) {
|
|
|
|
solver.Controller.Solutions = append(solver.Controller.Solutions, solver.renderCombination(solver.row1s[rows1Index], solver.row2s[rows2Index], solver.row3s[rows3Index], solver.row4s[rows4Index], solver.row5s[rows5Index], solver.row6s[rows6Index], solver.row7s[rows7Index], solver.row8s[rows8Index], solver.row9s[rows9Index]))
|
|
|
|
solver.Controller.Solutions = append(solver.Controller.Solutions, []string{solver.row1s[rows1Index], solver.row2s[rows2Index], solver.row3s[rows3Index], solver.row4s[rows4Index], solver.row5s[rows5Index], solver.row6s[rows6Index], solver.row7s[rows7Index], solver.row8s[rows8Index], solver.row9s[rows9Index]})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -194,53 +194,43 @@ func (solver *Solver) Tracker() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Validate combination
|
|
|
|
// Validate combination
|
|
|
|
func (solver *Solver) validateCombination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) (retval bool) {
|
|
|
|
func (solver *Solver) validateCombination(row1 string, row2 string, row3 string, row4 string, row5 string, row6 string, row7 string, row8 string, row9 string) (retval bool) {
|
|
|
|
retval = true
|
|
|
|
retval = true
|
|
|
|
|
|
|
|
|
|
|
|
row1s := strconv.Itoa(row1)
|
|
|
|
|
|
|
|
row2s := strconv.Itoa(row2)
|
|
|
|
|
|
|
|
row3s := strconv.Itoa(row3)
|
|
|
|
|
|
|
|
row4s := strconv.Itoa(row4)
|
|
|
|
|
|
|
|
row5s := strconv.Itoa(row5)
|
|
|
|
|
|
|
|
row6s := strconv.Itoa(row6)
|
|
|
|
|
|
|
|
row7s := strconv.Itoa(row7)
|
|
|
|
|
|
|
|
row8s := strconv.Itoa(row8)
|
|
|
|
|
|
|
|
row9s := strconv.Itoa(row9)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for index := range 9 {
|
|
|
|
for index := range 9 {
|
|
|
|
if row1s[index] == row2s[index] || row1s[index] == row3s[index] || row1s[index] == row4s[index] || row1s[index] == row5s[index] || row1s[index] == row6s[index] || row1s[index] == row7s[index] || row1s[index] == row8s[index] || row1s[index] == row9s[index] {
|
|
|
|
if row1[index] == row2[index] || row1[index] == row3[index] || row1[index] == row4[index] || row1[index] == row5[index] || row1[index] == row6[index] || row1[index] == row7[index] || row1[index] == row8[index] || row1[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row2s[index] == row1s[index] || row2s[index] == row3s[index] || row2s[index] == row4s[index] || row2s[index] == row5s[index] || row2s[index] == row6s[index] || row2s[index] == row7s[index] || row2s[index] == row8s[index] || row2s[index] == row9s[index] {
|
|
|
|
if row2[index] == row1[index] || row2[index] == row3[index] || row2[index] == row4[index] || row2[index] == row5[index] || row2[index] == row6[index] || row2[index] == row7[index] || row2[index] == row8[index] || row2[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row3s[index] == row1s[index] || row3s[index] == row2s[index] || row3s[index] == row4s[index] || row3s[index] == row5s[index] || row3s[index] == row6s[index] || row3s[index] == row7s[index] || row3s[index] == row8s[index] || row3s[index] == row9s[index] {
|
|
|
|
if row3[index] == row1[index] || row3[index] == row2[index] || row3[index] == row4[index] || row3[index] == row5[index] || row3[index] == row6[index] || row3[index] == row7[index] || row3[index] == row8[index] || row3[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row4s[index] == row1s[index] || row4s[index] == row2s[index] || row4s[index] == row3s[index] || row4s[index] == row5s[index] || row4s[index] == row6s[index] || row4s[index] == row7s[index] || row4s[index] == row8s[index] || row4s[index] == row9s[index] {
|
|
|
|
if row4[index] == row1[index] || row4[index] == row2[index] || row4[index] == row3[index] || row4[index] == row5[index] || row4[index] == row6[index] || row4[index] == row7[index] || row4[index] == row8[index] || row4[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row5s[index] == row1s[index] || row5s[index] == row2s[index] || row5s[index] == row3s[index] || row5s[index] == row4s[index] || row5s[index] == row6s[index] || row5s[index] == row7s[index] || row5s[index] == row8s[index] || row5s[index] == row9s[index] {
|
|
|
|
if row5[index] == row1[index] || row5[index] == row2[index] || row5[index] == row3[index] || row5[index] == row4[index] || row5[index] == row6[index] || row5[index] == row7[index] || row5[index] == row8[index] || row5[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row6s[index] == row1s[index] || row6s[index] == row2s[index] || row6s[index] == row3s[index] || row6s[index] == row4s[index] || row6s[index] == row5s[index] || row6s[index] == row7s[index] || row6s[index] == row8s[index] || row6s[index] == row9s[index] {
|
|
|
|
if row6[index] == row1[index] || row6[index] == row2[index] || row6[index] == row3[index] || row6[index] == row4[index] || row6[index] == row5[index] || row6[index] == row7[index] || row6[index] == row8[index] || row6[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row7s[index] == row1s[index] || row7s[index] == row2s[index] || row7s[index] == row3s[index] || row7s[index] == row4s[index] || row5s[index] == row6s[index] || row7s[index] == row6s[index] || row7s[index] == row8s[index] || row7s[index] == row9s[index] {
|
|
|
|
if row7[index] == row1[index] || row7[index] == row2[index] || row7[index] == row3[index] || row7[index] == row4[index] || row5[index] == row6[index] || row7[index] == row6[index] || row7[index] == row8[index] || row7[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row8s[index] == row1s[index] || row8s[index] == row2s[index] || row8s[index] == row3s[index] || row8s[index] == row4s[index] || row8s[index] == row5s[index] || row8s[index] == row6s[index] || row8s[index] == row7s[index] || row8s[index] == row9s[index] {
|
|
|
|
if row8[index] == row1[index] || row8[index] == row2[index] || row8[index] == row3[index] || row8[index] == row4[index] || row8[index] == row5[index] || row8[index] == row6[index] || row8[index] == row7[index] || row8[index] == row9[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if row9s[index] == row1s[index] || row9s[index] == row2s[index] || row9s[index] == row3s[index] || row9s[index] == row4s[index] || row9s[index] == row5s[index] || row9s[index] == row6s[index] || row9s[index] == row7s[index] || row9s[index] == row8s[index] {
|
|
|
|
if row9[index] == row1[index] || row9[index] == row2[index] || row9[index] == row3[index] || row9[index] == row4[index] || row9[index] == row5[index] || row9[index] == row6[index] || row9[index] == row7[index] || row9[index] == row8[index] {
|
|
|
|
retval = false
|
|
|
|
retval = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|