aoc2021/hs/01.1.hs
2021-12-02 18:17:46 +07:00

9 lines
295 B
Haskell

import System.IO
main = print . snd . foldl step (Nothing, 0) . map (read :: String -> Int) . lines =<< readFile "../input/01"
step (Nothing, sum) n = (Just n, sum)
step ((Just last), sum) n = (Just n, sum +
(if n > last then 1 else 0))
step :: (Maybe Int, Int) -> Int -> (Maybe Int, Int)