#2 Proper usage of range

This commit is contained in:
Sacha Ligthert 2025-01-23 23:11:30 +01:00
parent 81edc8962d
commit c9b05e7026
2 changed files with 5 additions and 5 deletions

View File

@ -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)
}
}

View File

@ -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)