AoC/2021/day01/day01.hs

10 lines
260 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
2021-12-09 23:43:50 +01:00
print $
day1 $ zipWith3 (\x y z -> x + y + z) input (tail input) (tail $ tail input)
2021-12-05 19:47:42 +01:00
day1 :: [Int] -> Int
day1 a = sum $ map fromEnum $ zipWith (<) a (tail a)