You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
354 B
17 lines
354 B
module Main where
|
|
|
|
main :: IO ()
|
|
main = interact solution
|
|
|
|
windows :: Int -> [a] -> [[a]]
|
|
windows _ [] = []
|
|
windows n (a:r) = take n (a:r) : windows n r
|
|
|
|
solution :: String -> String
|
|
solution = show
|
|
. sum
|
|
. map (fromEnum . \(a:b:_) -> a < b)
|
|
. init
|
|
. windows 2
|
|
. map (read :: String -> Int)
|
|
. lines
|