aoc-2021/day1/first.hs

10 lines
301 B
Haskell

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