From c9b05e7026b855df307ba8e71f743bfb73a78af2 Mon Sep 17 00:00:00 2001 From: Sacha Ligthert Date: Thu, 23 Jan 2025 23:11:30 +0100 Subject: [PATCH] #2 Proper usage of `range` --- solver/printers.go | 6 +++--- solver/processing.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/solver/printers.go b/solver/printers.go index b688348..0235b5c 100644 --- a/solver/printers.go +++ b/solver/printers.go @@ -6,8 +6,8 @@ import ( ) func (solver *Solver) print_solutions() { - for solutions := range solver.solutions { - log.Printf("\nSolution #%d:", solutions+1) - fmt.Println(solver.solutions[solutions]) + for solution_index, solution := range solver.solutions { + log.Printf("\nSolution #%d:", solution_index+1) + fmt.Println(solution) } } diff --git a/solver/processing.go b/solver/processing.go index 85e08a9..136676e 100644 --- a/solver/processing.go +++ b/solver/processing.go @@ -41,9 +41,9 @@ func (solver *Solver) find_blocks(row *string, rows *[]int) { selection = nil } - for block := range curr_blocks { + for _, block := range curr_blocks { - curr_row := strconv.Itoa(curr_blocks[block]) + curr_row := strconv.Itoa(block) if func_row[letter] == curr_row[letter] { found_row, _ := strconv.Atoi(curr_row)