Last active
December 3, 2019 09:18
-
-
Save saninmersion/87b1472be65a5fd00b38fee6640bf13c to your computer and use it in GitHub Desktop.
Advent of Code 2019 solutions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let totalFuel = inputs.reduce( (acc, mass) => (acc + Math.floor((mass / 3 - 2 )), 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recursiveFuel(mass){ | |
let initialFuel = Math.floor( mass / 3 - 2 ) | |
return (initialFuel <= 0) ? 0 : initialFuel + recursiveFuel(initialFuel) | |
} | |
let totalFuel = inputs.reduce( (acc, mass) => (acc + recursiveFuel(mass)), 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment