alan rewite day1 haskell

This commit is contained in:
Alan Evans
2021-12-07 20:51:17 +00:00
parent 96ddc03b69
commit e3eab87b08
5 changed files with 2047 additions and 20 deletions

16
day1/day1_p1.hs Normal file
View File

@@ -0,0 +1,16 @@
import Data.List
main :: IO ()
main = do
input <- readFile "input.txt"
print . count . map read $ words input
count :: [Int] -> Int
count (x:xs) = count_f x xs
count_f :: Int -> [Int] -> Int
count_f _ [] = 0
count_f nb (x:xs)
| x > nb = 1 + count_f x xs
| otherwise = count_f x xs