Skip to content

Commit fe115e2

Browse files
committed
Day 9: Use foldl in collectBasin
1 parent 1abe238 commit fe115e2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

2021/9/main.hs

+1-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ part1 m = sum $ map (riskLevel m) $ localMinima (0, 0) m
3131
contains p l = any (== p) l
3232

3333
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
34+
then foldl (collectBasin m) (p:s) (neighbours p)
3935
else s
4036

4137
collectBasins m = map (collectBasin m [])

0 commit comments

Comments
 (0)