2024-12-05 17:46:09 +01:00
|
|
|
package main
|
|
|
|
|
2025-01-21 21:43:27 +01:00
|
|
|
import (
|
2025-01-27 21:47:35 +01:00
|
|
|
"log"
|
|
|
|
"runtime"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"gitea.ligthert.net/golang/sudoku-funpark/flags"
|
2025-01-21 21:43:27 +01:00
|
|
|
"gitea.ligthert.net/golang/sudoku-funpark/solver"
|
|
|
|
)
|
2024-12-05 17:46:09 +01:00
|
|
|
|
|
|
|
func main() {
|
2025-01-27 21:47:35 +01:00
|
|
|
// Instantiate the interfaces
|
|
|
|
solver := solver.Solver{}
|
|
|
|
flags := flags.Flags{}
|
|
|
|
|
|
|
|
// Parse and handle flags
|
|
|
|
flags.ParseFlags()
|
|
|
|
flags.TransferConfig(&solver)
|
|
|
|
|
|
|
|
// Report number of CPUs being used, if set.
|
|
|
|
if runtime.NumCPU() != solver.NumCPUs {
|
|
|
|
log.Println("Using " + strconv.Itoa(solver.NumCPUs) + " CPUs, (was " + strconv.Itoa(runtime.NumCPU()) + ")")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load blocks from CSV file
|
|
|
|
solver.LoadBlocks()
|
|
|
|
|
|
|
|
// Find rows that fit with the entered rows
|
|
|
|
solver.PopulateBlocks()
|
|
|
|
|
|
|
|
// If needed, split the workload
|
|
|
|
// May exit and throw an error if the work load isn't viable
|
|
|
|
if solver.Split != 1 {
|
|
|
|
solver.SelectWorkload()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the total number of solutions to validate
|
|
|
|
log.Println("Number of (potential) solutions:", solver.Iter)
|
|
|
|
|
|
|
|
// Check the number of solutions
|
|
|
|
go solver.CheckCombinations()
|
|
|
|
solver.Tracker()
|
|
|
|
|
|
|
|
// Print the valid solutions
|
|
|
|
solver.PrintSolutions()
|
2024-12-06 19:28:24 +01:00
|
|
|
}
|