Working. 1 hour for this set.

This commit is contained in:
Sacha Ligthert 2024-12-08 01:28:32 +01:00
parent b89d2d29c6
commit 7aebaea676
3 changed files with 3 additions and 32 deletions

@ -57,13 +57,9 @@ func (solver *Solver) check_combinations() {
for rows6_index := range solver.row6s {
for rows7_index := range solver.row7s {
for rows8_index := range solver.row8s {
defer solver.wg.Done()
solver.wg.Add(1)
go solver.routine_row8(rows1_index, rows2_index, rows3_index, rows4_index, rows5_index, rows6_index, rows7_index, rows8_index)
// for rows9_index := range solver.row9s {
// go solver.routine_validator(rows1_index, rows2_index, rows3_index, rows4_index, rows5_index, rows6_index, rows7_index, rows8_index, rows9_index)
// // }
// }
for rows9_index := range solver.row9s {
go solver.routine_validator(rows1_index, rows2_index, rows3_index, rows4_index, rows5_index, rows6_index, rows7_index, rows8_index, rows9_index)
}
}
}
}
@ -75,72 +71,54 @@ func (solver *Solver) check_combinations() {
}
func (solver *Solver) routine_row1(index1 int) {
defer solver.wg.Done()
for index2 := range solver.row2s {
solver.wg.Add(1)
go solver.routine_row2(index1, index2)
}
}
func (solver *Solver) routine_row2(index1 int, index2 int) {
defer solver.wg.Done()
for index3 := range solver.row3s {
solver.wg.Add(1)
go solver.routine_row3(index1, index2, index3)
}
}
func (solver *Solver) routine_row3(index1 int, index2 int, index3 int) {
defer solver.wg.Done()
for index4 := range solver.row4s {
solver.wg.Add(1)
go solver.routine_row4(index1, index2, index3, index4)
}
}
func (solver *Solver) routine_row4(index1 int, index2 int, index3 int, index4 int) {
defer solver.wg.Done()
for index5 := range solver.row5s {
solver.wg.Add(1)
go solver.routine_row5(index1, index2, index3, index4, index5)
}
}
func (solver *Solver) routine_row5(index1 int, index2 int, index3 int, index4 int, index5 int) {
defer solver.wg.Done()
for index6 := range solver.row6s {
solver.wg.Add(1)
go solver.routine_row6(index1, index2, index3, index4, index5, index6)
}
}
func (solver *Solver) routine_row6(index1 int, index2 int, index3 int, index4 int, index5 int, index6 int) {
defer solver.wg.Done()
for index7 := range solver.row7s {
solver.wg.Add(1)
go solver.routine_row7(index1, index2, index3, index4, index5, index6, index7)
}
}
func (solver *Solver) routine_row7(index1 int, index2 int, index3 int, index4 int, index5 int, index6 int, index7 int) {
defer solver.wg.Done()
for index8 := range solver.row8s {
solver.wg.Add(1)
go solver.routine_row8(index1, index2, index3, index4, index5, index6, index7, index8)
}
}
func (solver *Solver) routine_row8(index1 int, index2 int, index3 int, index4 int, index5 int, index6 int, index7 int, index8 int) {
defer solver.wg.Done()
for index9 := range solver.row9s {
solver.wg.Add(1)
go solver.routine_row9(index1, index2, index3, index4, index5, index6, index7, index8, index9)
}
}
func (solver *Solver) routine_row9(index1 int, index2 int, index3 int, index4 int, index5 int, index6 int, index7 int, index8 int, index9 int) {
defer solver.wg.Done()
solver.wg.Add(1)
go solver.routine_validator(index1, index2, index3, index4, index5, index6, index7, index8, index9)
}
@ -159,8 +137,6 @@ func (solver *Solver) routine_validator(rows1_index int, rows2_index int, rows3_
fmt.Println("Processing:", percentage, "%; Procs:", runtime.NumGoroutine())
}
solver.wg.Done()
}
func (solver *Solver) validate_combination(row1 int, row2 int, row3 int, row4 int, row5 int, row6 int, row7 int, row8 int, row9 int) bool {

@ -2,7 +2,6 @@ package solver
import (
"fmt"
"sync"
)
func Run() {
@ -16,7 +15,6 @@ func Run() {
solver.row7 = "597410280"
solver.row8 = "006283090"
solver.row9 = "200590006"
solver.wg = sync.WaitGroup{}
solver.load_blocks()
fmt.Println("Total blocks:", len(solver.blocks))

@ -1,7 +1,5 @@
package solver
import "sync"
type Solver struct {
blocks []int
row1 string
@ -25,5 +23,4 @@ type Solver struct {
iter int
counter int
solutions []string
wg sync.WaitGroup
}