Change haskell solution to handle bigint input

This commit is contained in:
kageru 2019-12-01 10:19:49 +01:00
parent c158f59eff
commit cbec64cf35
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -8,10 +8,10 @@ main = do
printf "Part 1: %d\n" (fuel input)
printf "Part 2: %d\n" (fuelrec input)
fuel :: [Int] -> Int
fuel :: [Integer] -> Integer
fuel xs = sum (map (subtract 2 . (`div` 3)) xs)
fuelrec :: [Int] -> Int
fuelrec :: [Integer] -> Integer
fuelrec xs = sum (map f xs) - sum xs where
f x | x > 0 = x + f ((subtract 2 . (`div` 3)) x)
| otherwise = 0