Day 20 shave off some cycles

This commit is contained in:
Christian
2024-12-20 19:17:00 +01:00
parent cdf14fdada
commit 58710aca7a

View File

@@ -20,11 +20,11 @@ object Day20 extends Solver(20):
def cheats(radius: Int): Int = def cheats(radius: Int): Int =
trace.indices.par trace.indices.par
.map(a => .map(toDist =>
(a + 1 until trace.length) (toDist + 100 until trace.length)
.count(b => .count(fromDist =>
val (from, fromDist) = (trace(a), trace.length - a) val from = trace(toDist)
val (to, toDist) = (trace(b), trace.length - b) val to = trace(fromDist)
val dist = (from - to).manhattan val dist = (from - to).manhattan
dist <= radius && (fromDist - toDist >= 100 + dist) dist <= radius && (fromDist - toDist >= 100 + dist)