advent-of-code/2023/9/Main2.hs

13 lines
303 B
Haskell
Raw Normal View History

2023-12-09 00:01:25 -08:00
import Data.List.Split (splitOn)
solve :: [Int] -> Int
solve [] = 0
solve xs@(x:_) = x + solve (getDifferences xs)
where
getDifferences = zipWith (-) <*> tail
main :: IO ()
main = print . sum . map solveLine . lines =<< readFile "data.txt"
where
solveLine = solve . map read . splitOn " "