diff options
Diffstat (limited to 'solutions/py/01-2.py')
| -rw-r--r-- | solutions/py/01-2.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/solutions/py/01-2.py b/solutions/py/01-2.py new file mode 100644 index 0000000..0017a8b --- /dev/null +++ b/solutions/py/01-2.py @@ -0,0 +1,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)) |
