aoc/2019/01/01.py
2020-12-11 15:16:01 -06:00

15 lines
397 B
Python

with open("input.txt","r") as f:
masses = [int(x) for x in f.read().split('\n')]
def fuel_required(mass):
return mass // 3 - 2
def fuel_required_recursive(mass):
fuel = mass // 3 - 2
if fuel <= 0:
return 0
return fuel + fuel_required_recursive(fuel)
part1 = sum([fuel_required(mass) for mass in masses])
part2 = sum([fuel_required_recursive(mass) for mass in masses])
print(part1, part2)