X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent01%2FMain.hs;h=8c95a92d4c83caa89d16d5d2a4581a180e1bb488;hb=6f75b7d1d52146a5acf6aab7cfc4d8388b91fc3d;hp=535fdf45410bf4884cc4103e426c6e25c079b69a;hpb=30f2ac165744b80139e28c783aa4d0f0ac122e87;p=advent-of-code-21.git

diff --git a/advent01/Main.hs b/advent01/Main.hs
index 535fdf4..8c95a92 100644
--- a/advent01/Main.hs
+++ b/advent01/Main.hs
@@ -1,3 +1,5 @@
+-- Writeup at https://work.njae.me.uk/2021/12/01/advent-of-code-2021-day-1/
+
 import Data.List
 
 main :: IO ()
@@ -12,7 +14,7 @@ part1 = countIncreasing
 
 part2 :: [Int] -> Int
 part2 nums = countIncreasing $ map sum windows
-  where windows = filter (\w -> length w == 3) $ map (take 3) $ tails nums
+  where windows = filter ((== 3) . length) $ map (take 3) $ tails nums
 
 countIncreasing :: [Int] -> Int
-countIncreasing nums = length $ filter (> 0) $ zipWith (-) (tail nums) nums
+countIncreasing nums = length $ filter (uncurry (>)) $ zip (tail nums) nums