AoC/2023/day09/day09.hs
Gattix c970abf345 day09: remove f
the wisdom of Karl has spoken
2023-12-09 17:42:03 +01:00

18 lines
359 B
Haskell

import Control.Arrow
main :: IO ()
main = do
input <- parse <$> readFile "input"
print $ day09 input
parse :: String -> [[Int]]
parse = map (map read . words) . lines
day09 :: [[Int]] -> (Int, Int)
day09 =
(sum *** sum) .
unzip .
map
((sum . map last &&& foldr1 (-) . map head) .
takeWhile (not . null) . iterate (zipWith (-) =<< tail))