File tree 1 file changed +4
-6
lines changed
src/main/scala/eu/sim642/adventofcode2024
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,12 @@ object Day20 {
41
41
(cell, x) <- row.view.zipWithIndex
42
42
if cell != '#'
43
43
start = Pos (x, y)
44
- xOffset <- - maxCheat to maxCheat
45
- pos = start + Pos (xOffset, 0 )
46
- if grid.containsPos(pos)
44
+ xOffset <- - (maxCheat min x) to (maxCheat min (grid(0 ).size - 1 - x))
47
45
startCheat = xOffset.abs
48
46
maxEndCheat = maxCheat - startCheat
49
- yOffset <- ( - maxEndCheat) to maxEndCheat
50
- end = pos + Pos (0 , yOffset)
51
- if grid.containsPos(end) && grid (end) != '#'
47
+ yOffset <- - ( maxEndCheat min y ) to ( maxEndCheat min (grid.size - 1 - y))
48
+ end = start + Pos (xOffset , yOffset)
49
+ if grid(end) != '#'
52
50
endCheat = yOffset.abs
53
51
cheatDistance = forwardResult.distances(start) + (startCheat + endCheat) + backwardResult.distances(end)
54
52
// if cheatDistance <= noCheatDistance
You can’t perform that action at this time.
0 commit comments