We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1abe238 commit fe115e2Copy full SHA for fe115e2
2021/9/main.hs
@@ -31,11 +31,7 @@ part1 m = sum $ map (riskLevel m) $ localMinima (0, 0) m
31
contains p l = any (== p) l
32
33
collectBasin m s p@(x, y) = if point m p < 9 && not (contains p s)
34
- then let [a,b,c,d] = neighbours p
35
- b' = collectBasin m (p:s) a
36
- c' = collectBasin m b' b
37
- d' = collectBasin m c' c
38
- in collectBasin m d' d
+ then foldl (collectBasin m) (p:s) (neighbours p)
39
else s
40
41
collectBasins m = map (collectBasin m [])
0 commit comments