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