AoC/2023/day09/day09.hs
Gattix b8a31b37a6 day09: switch to interact
needs more golfing
also interact is probably better anyway
2023-12-09 18:54:28 +01:00

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))