c970abf345
the wisdom of Karl has spoken
18 lines
359 B
Haskell
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))
|