AoC/2021/day01/day01.hs

10 lines
251 B
Haskell
Raw Normal View History

2021-12-05 19:47:42 +01:00
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)