Selaa lähdekoodia

#2 Proper usage of `range`

Sacha Ligthert 1 vuosi sitten
vanhempi
sitoutus
c9b05e7026
2 muutettua tiedostoa jossa 5 lisäystä ja 5 poistoa
  1. 3 3
      solver/printers.go
  2. 2 2
      solver/processing.go

+ 3 - 3
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)
 	}
 }

+ 2 - 2
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)