File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
src/main/scala/eu/sim642/adventofcode2024 Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,12 @@ object Day20 {
4141 (cell, x) <- row.view.zipWithIndex
4242 if cell != '#'
4343 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))
4745 startCheat = xOffset.abs
4846 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) != '#'
5250 endCheat = yOffset.abs
5351 cheatDistance = forwardResult.distances(start) + (startCheat + endCheat) + backwardResult.distances(end)
5452 // if cheatDistance <= noCheatDistance
You can’t perform that action at this time.
0 commit comments