]> fbox.kageds.com Git - adventofcode.git/blob - day1/day1_p1.hs
tidy up
[adventofcode.git] / day1 / day1_p1.hs
1 import Data.List
2
3 main :: IO ()
4 main = do
5 input <- readFile "input.txt"
6 print . count . map read $ words input
7
8 count :: [Int] -> Int
9 count (x:xs) = count_f x xs
10
11 count_f :: Int -> [Int] -> Int
12 count_f _ [] = 0
13 count_f nb (x:xs)
14 | x > nb = 1 + count_f x xs
15 | otherwise = count_f x xs
16