blob: 95c5e4b129e1047daad796b0276b734e168f9307 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
module Main where
import Utils
diff :: [Int] -> [Int]
diff [] = []
diff xs = zipWith (-) (tail xs) xs
e1 :: [Int] -> Int
e1 = diff .> filter (> 0) .> length
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 $> print
e2 ints $> print
|