this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at d09cbade53a0d3e704dcbf42bd5df4d55ab4d307 14 lines 423 B view raw
1module Lib where 2 3fuelNeeded :: [String] -> Int 4fuelNeeded = sum . map (addRemainingFuel . fuelFromMass) . map (\w -> read w :: Int) 5 6fuelFromMass :: Int -> Int 7fuelFromMass x = (x `div` 3) - 2 8 9addRemainingFuel :: Int -> Int 10addRemainingFuel x = sum $ go [x] x 11 where go :: [Int] -> Int -> [Int] 12 go xs x' 13 | fuelFromMass x' > 0 = go (xs ++ [fuelFromMass x']) $ fuelFromMass x' 14 | otherwise = xs