Skip to content

Instantly share code, notes, and snippets.

@tapionx
Created December 1, 2019 16:09
Show Gist options
  • Save tapionx/21f3055dbf98c903104b7faf0c80bd85 to your computer and use it in GitHub Desktop.
Save tapionx/21f3055dbf98c903104b7faf0c80bd85 to your computer and use it in GitHub Desktop.
Advent of Code 2019 #2 solution
with open('1_input.txt', 'r') as f:
input_data = f.readlines()
def fuel_requirement(mass):
fuel_needed = (mass / 3) - 2
if fuel_needed > 0:
return fuel_needed + fuel_requirement(fuel_needed)
else:
return 0
print(fuel_requirement(14))
print(fuel_requirement(1969))
print(fuel_requirement(100756))
fuel_sum = 0
for module_mass in input_data:
fuel_sum += fuel_requirement(int(module_mass))
print(fuel_sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment