We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37e586e commit 6191a6eCopy full SHA for 6191a6e
reflections/2024/day20.md
@@ -42,10 +42,8 @@ findCheats walls start end len thresh = do
42
go (i, xs) x =
43
( (i + 1, M.insert x i xs)
44
, M.size $
45
- M.filterWithKey (\y j -> i - j - mannDist x y >= thresh) $
46
- xs `M.restrictKeys` S.mapMonotonic (+ x) diamond
+ M.filterWithKey (\y j -> let d = mannDist x y in d <= len && i - j - d >= thresh) xs
47
)
48
- diamond = floodFill (S.filter ((<= len) . mannNorm) . cardinalNeighbsSet) (S.singleton 0)
49
```
50
51
Our `mapAccumR` here iterates from the end of the list with the index (`i`) and
0 commit comments