-
-
Save tapionx/d83c3e0c360491f3e6985a355073e012 to your computer and use it in GitHub Desktop.
Advent of Code 2019 #1 solution
This file contains 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
with open('1_input.txt', 'r') as f: | |
input_data = f.readlines() | |
def fuel_requirement(mass): | |
fuel_needed = (mass / 3) - 2 | |
while fuel_needed > 0: | |
fuel_needed += (fuel_needed / 3) - 2 | |
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