Piotr Czajkowski 2 settimane fa
parent
commit
4846c4faed
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      07/code.go

+ 5 - 1
07/code.go

@@ -66,6 +66,10 @@ func check(equation Equation, index, result int) bool {
 	}
 
 	resultAdd := check(equation, index+1, result+equation.numbers[index])
+
+	if result == 0 {
+		result++
+	}
 	resultMul := check(equation, index+1, result*equation.numbers[index])
 
 	if resultAdd {
@@ -78,7 +82,7 @@ func check(equation Equation, index, result int) bool {
 func part1(equations []Equation) int {
 	var result int
 	for _, equation := range equations {
-		if check(equation, 0, 1) {
+		if check(equation, 0, 0) {
 			result += equation.result
 		}
 	}