Enable nicer logging.

This commit is contained in:
Sacha Ligthert 2025-01-21 21:43:27 +01:00
parent 5a9f22edb7
commit 8ec56bc3d8
3 changed files with 15 additions and 7 deletions

11
main.go
View File

@ -1,7 +1,16 @@
package main
import "gitea.ligthert.net/golang/sudoku-funpark/solver"
import (
"log"
"gitea.ligthert.net/golang/sudoku-funpark/solver"
)
func main() {
// Set global logger parameters
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.Lshortfile)
// Run the meat of the program
solver.Run()
}

View File

@ -1,7 +1,7 @@
package solver
import (
"fmt"
"log"
"runtime"
"strconv"
)
@ -27,7 +27,6 @@ func (solver *Solver) find_blocks(row *string, rows *[]int) {
var curr_blocks []int
func_row := *row
// fmt.Println(row)
for letter := range func_row {
if len(selection) == 0 {
@ -91,7 +90,7 @@ func (solver *Solver) routine_validator(rows1_index int, rows2_index int, rows3_
if solver.counter%1000000 == 0 {
percentage = (float32(solver.counter) / (float32(solver.iter) / 100))
fmt.Println("Processing:", percentage, "%; Procs:", runtime.NumGoroutine())
log.Println("Processing:", percentage, "%; Procs:", runtime.NumGoroutine())
}
}

View File

@ -1,7 +1,7 @@
package solver
import (
"fmt"
"log"
)
func Run() {
@ -25,12 +25,12 @@ func Run() {
solver.populate_blocks()
// Print the total number of solutions to validate
fmt.Println("Number of solutions:", solver.iter)
log.Println("Number of solutions:", solver.iter)
// Check the number of solutions
solver.check_combinations()
// Print the valid solutions
fmt.Println(solver.solutions)
log.Println(solver.solutions)
}