13 lines
313 B
Haskell
13 lines
313 B
Haskell
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 " "
|