diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-04 07:02:31 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2019-12-04 07:02:31 +0100 |
| commit | 831755fdc6d430bd8781da1897270cf2934bc858 (patch) | |
| tree | f1d6e5609363f98534a87eb9203a7623fb409371 /solutions/py/01-2.py | |
| download | aoc-831755fdc6d430bd8781da1897270cf2934bc858.tar.gz | |
Initial commit
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)) |
