blob: e4dbb1b3109d3fe6734d329ad6e4e1a54c9c83d3 (
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
25
26
27
28
29
30
31
|
module Main where
import Utils
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
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
main :: IO ()
main =
do
contents <- getContents
let ints = map read (lines contents)
e1 ints
e2 ints
|