Day 20 shave off some cycles
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user