Skip to content

Instantly share code, notes, and snippets.

@saninmersion
Last active December 3, 2019 09:18
Show Gist options
  • Save saninmersion/87b1472be65a5fd00b38fee6640bf13c to your computer and use it in GitHub Desktop.
Save saninmersion/87b1472be65a5fd00b38fee6640bf13c to your computer and use it in GitHub Desktop.
Advent of Code 2019 solutions
let totalFuel = inputs.reduce( (acc, mass) => (acc + Math.floor((mass / 3 - 2 )), 0)
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