22 lines
532 B
Python
22 lines
532 B
Python
def calculate_fuel(mass):
|
|
return mass // 3 - 2
|
|
|
|
def calculate_fuel2(mass):
|
|
fuel = mass // 3 - 2
|
|
if fuel < 0:
|
|
return 0
|
|
else:
|
|
return fuel + calculate_fuel2(fuel)
|
|
|
|
if __name__ == '__main__':
|
|
with open('../input') as f:
|
|
content = f.readlines()
|
|
|
|
modules = [int(x.strip()) for x in content]
|
|
|
|
fuel1 = [calculate_fuel(x) for x in modules]
|
|
fuel2 = [calculate_fuel2(x) for x in modules]
|
|
|
|
print("Solution for Part One: ", sum(fuel1))
|
|
print("Solution for Part Two: ", sum(fuel2))
|