blob: 0017a8be0b4d3029bb5a9f58e1df6e354dce703f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import math
import sys
def get_fuel(mass):
fuel = math.floor(mass / 3) - 2
if fuel <= 0:
return 0
return fuel + get_fuel(fuel)
fuels = []
for line in sys.stdin:
if line.rstrip() == "":
break
fuels.append(get_fuel(int(line)))
print(sum(fuels))
|