Forked from AmandaLowery/gist:4e747cfeae429bed0ffc5d55999ded8e
Created
December 5, 2019 00:51
-
-
Save chadsten/b51f1bfc4dee1bbbf359034eeb52f5b3 to your computer and use it in GitHub Desktop.
Day 1 Part 2
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("Day1_input.txt", "r") as f: | |
modules = [int(x) for x in f.readlines()] | |
#part 1 | |
fuel = sum((y // 3 - 2) for y in modules) | |
print(fuel) | |
#3390596 | |
#holyshit | |
#part 2 | |
total_fuel = 0 | |
for y in modules: | |
fuel_added = y | |
while True: | |
fuel_added = (y // 3 - 2) | |
if fuel_added > 0: | |
total_fuel += fuel_added | |
else: | |
break | |
print(total_fuel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment