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 =
trace.indices.par
.map(a =>
(a + 1 until trace.length)
.count(b =>
val (from, fromDist) = (trace(a), trace.length - a)
val (to, toDist) = (trace(b), trace.length - b)
.map(toDist =>
(toDist + 100 until trace.length)
.count(fromDist =>
val from = trace(toDist)
val to = trace(fromDist)
val dist = (from - to).manhattan
dist <= radius && (fromDist - toDist >= 100 + dist)