aoc-2021/day1/first.hs

10 lines
301 B
Haskell
Raw Normal View History

2021-12-01 07:47:08 +00:00
loop :: Int -> [Int] -> Int -> Int
loop _ [] acc = acc
loop prev (curr:rest) acc
| prev < curr = loop curr rest (acc + 1)
| otherwise = loop curr rest acc
main = interact $ solution . getInput
where solution input = show $ loop (head input) (tail input) 0
getInput = map read . words