Skip to content

Commit 6191a6e

Browse files
committed
simplify day 20 reflection
1 parent 37e586e commit 6191a6e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

reflections/2024/day20.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ findCheats walls start end len thresh = do
4242
go (i, xs) x =
4343
( (i + 1, M.insert x i xs)
4444
, M.size $
45-
M.filterWithKey (\y j -> i - j - mannDist x y >= thresh) $
46-
xs `M.restrictKeys` S.mapMonotonic (+ x) diamond
45+
M.filterWithKey (\y j -> let d = mannDist x y in d <= len && i - j - d >= thresh) xs
4746
)
48-
diamond = floodFill (S.filter ((<= len) . mannNorm) . cardinalNeighbsSet) (S.singleton 0)
4947
```
5048

5149
Our `mapAccumR` here iterates from the end of the list with the index (`i`) and

0 commit comments

Comments
 (0)