Piotr Czajkowski 2 týždňov pred
rodič
commit
e6404f1428
1 zmenil súbory, kde vykonal 2 pridanie a 4 odobranie
  1. 2 4
      03/code.go

+ 2 - 4
03/code.go

@@ -59,7 +59,7 @@ func part2(lines []string) int {
 	multiply := true
 
 	for _, line := range lines {
-		var startIndex, endIndex int
+		var endIndex int
 		reading := true
 		for reading {
 			if multiply {
@@ -72,17 +72,15 @@ func part2(lines []string) int {
 					endIndex = index
 				}
 
-				result += getResults(line[startIndex:endIndex])
+				result += getResults(line[:endIndex])
 
 				line = line[endIndex:]
-				startIndex = 0
 			} else {
 				index := strings.Index(line, "do()")
 				if index == -1 {
 					reading = false
 				} else {
 					multiply = true
-					startIndex = 0
 					line = line[index:]
 				}
 			}