diff --git a/2019/d01/ex2/ex2.py b/2019/d01/ex2/ex2.py new file mode 100755 index 0000000..6e4620c --- /dev/null +++ b/2019/d01/ex2/ex2.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import sys + + +def calc_fuel(mass: int) -> int: + fuel = mass // 3 - 2 + return fuel + calc_fuel(fuel) if fuel > 0 else 0 + + +def main() -> None: + print(sum(calc_fuel(int(l)) for l in sys.stdin)) + + +if __name__ == "__main__": + main()