X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=advent01%2FMain.hs;h=a52bf9c1a6bd597c69118aab6f859eb5eb1cb3af;hb=28092a7c519e402030b0b2a40619312d9da87fbd;hp=535fdf45410bf4884cc4103e426c6e25c079b69a;hpb=30f2ac165744b80139e28c783aa4d0f0ac122e87;p=advent-of-code-21.git diff --git a/advent01/Main.hs b/advent01/Main.hs index 535fdf4..a52bf9c 100644 --- a/advent01/Main.hs +++ b/advent01/Main.hs @@ -12,7 +12,8 @@ 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 (> 0) $ zipWith (-) (tail nums) nums +countIncreasing nums = length $ filter (uncurry (>)) $ zip (tail nums) nums