Skip to content

Instantly share code, notes, and snippets.

@joaoqalves
Created December 3, 2019 19:31
Show Gist options
  • Save joaoqalves/739236b547fafb60acf7371f506957a4 to your computer and use it in GitHub Desktop.
Save joaoqalves/739236b547fafb60acf7371f506957a4 to your computer and use it in GitHub Desktop.
AoC 2019 #1
def fuel_req(mass):
fuel = (mass // 3) - 2
if fuel <= 0:
return 0
else:
return fuel + fuel_req(fuel)
total = 0
with open('/Users/joaoqalves/Desktop/puzzle.txt', 'r') as puzzle:
for line in puzzle.readlines():
total += fuel_req(int(line))
print(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment