diff options
Diffstat (limited to 'day01/main.hs')
| -rw-r--r-- | day01/main.hs | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/day01/main.hs b/day01/main.hs index e4dbb1b..95c5e4b 100644 --- a/day01/main.hs +++ b/day01/main.hs @@ -6,26 +6,19 @@ diff :: [Int] -> [Int] diff [] = [] diff xs = zipWith (-) (tail xs) xs -e1 :: [Int] -> IO () -e1 ints = do - let result = ints $> diff .> filter (> 0) .> length - print result +e1 :: [Int] -> Int +e1 = diff .> filter (> 0) .> length -e2 :: [Int] -> IO () -e2 ints = do - let result = - zip3 ints (tail ints) (tail (tail ints)) - $> map (\(x, y, z) -> x + y + z) - .> diff - .> filter (> 0) - .> length - - print result +e2 :: [Int] -> Int +e2 ints = + zip3 ints (tail ints) (tail $ tail ints) + $> map (\(x, y, z) -> x + y + z) + .> e1 main :: IO () main = do contents <- getContents let ints = map read (lines contents) - e1 ints - e2 ints + e1 ints $> print + e2 ints $> print |
