0e134abdaa
p2 is just reverse p1 lol
15 lines
321 B
Haskell
15 lines
321 B
Haskell
import Control.Arrow
|
|
|
|
main :: IO ()
|
|
main = do
|
|
input <- parse <$> readFile "input"
|
|
print $ (day09 &&& day09 . map reverse) input
|
|
|
|
parse :: String -> [[Int]]
|
|
parse = map (map read . words) . lines
|
|
|
|
day09 :: [[Int]] -> Int
|
|
day09 =
|
|
sum .
|
|
map (sum . map last . takeWhile (not . null) . iterate (zipWith (-) =<< tail))
|