Skip to content

Instantly share code, notes, and snippets.

@tranzystorekk
Created December 2, 2019 00:32
Show Gist options
  • Save tranzystorekk/314bd14671060d2cc324133d9d31aa3e to your computer and use it in GitHub Desktop.
Save tranzystorekk/314bd14671060d2cc324133d9d31aa3e to your computer and use it in GitHub Desktop.
AoC 2019 day1 part2 Haskell
fuelReq :: Int -> Int
fuelReq m = div m 3 - 2
fuelChain :: Int -> [Int]
fuelChain m = takeWhile (> 0) (iterate fuelReq m)
totalFuel = sum $ map (sum . fuelChain) [1, 2, 3, 4, 5] -- <- module masses here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment