AoC/2021/day01/day01.hs
2021-12-09 23:43:50 +01:00

10 lines
260 B
Haskell

main :: IO ()
main = do
input <- map read . lines <$> readFile "input"
print $ day1 input
print $
day1 $ zipWith3 (\x y z -> x + y + z) input (tail input) (tail $ tail input)
day1 :: [Int] -> Int
day1 a = sum $ map fromEnum $ zipWith (<) a (tail a)