|
@@ -94,13 +94,13 @@ func part2(lines []Line) int {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
|
|
- found := false
|
|
|
|
for j := 3; j < 6; j++ {
|
|
for j := 3; j < 6; j++ {
|
|
- if index+j > end {
|
|
|
|
|
|
+ edge := index + j
|
|
|
|
+ if edge > end {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
|
|
|
|
- value, ok := digits[line[index:index+j]]
|
|
|
|
|
|
+ value, ok := digits[line[index:edge]]
|
|
if ok {
|
|
if ok {
|
|
digit = value
|
|
digit = value
|
|
if !haveFirst {
|
|
if !haveFirst {
|
|
@@ -108,15 +108,11 @@ func part2(lines []Line) int {
|
|
haveFirst = true
|
|
haveFirst = true
|
|
}
|
|
}
|
|
|
|
|
|
- index += j
|
|
|
|
- found = true
|
|
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if !found {
|
|
|
|
- index++
|
|
|
|
- }
|
|
|
|
|
|
+ index++
|
|
}
|
|
}
|
|
|
|
|
|
number += int(digit - delta)
|
|
number += int(digit - delta)
|