b8a31b37a6
needs more golfing also interact is probably better anyway
13 lines
290 B
Haskell
13 lines
290 B
Haskell
import Control.Arrow
|
|
|
|
main :: IO ()
|
|
main = interact $ show . (day09 &&& day09 . map reverse) . parse
|
|
|
|
parse :: String -> [[Int]]
|
|
parse = map (map read . words) . lines
|
|
|
|
day09 :: [[Int]] -> Int
|
|
day09 =
|
|
sum .
|
|
map (sum . map last . takeWhile (not . null) . iterate (zipWith (-) =<< tail))
|