Created
December 3, 2019 19:31
-
-
Save joaoqalves/739236b547fafb60acf7371f506957a4 to your computer and use it in GitHub Desktop.
AoC 2019 #1
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
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