aoc2021/hs/01.1.hs

9 lines
295 B
Haskell
Raw Normal View History

2021-12-02 18:13:56 +07:00
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)