2019: d01: ex2: add solution

This commit is contained in:
Bruno BELANYI 2019-12-08 18:12:09 +01:00
parent 6a00802583
commit c4fa0cbc6a

15
2019/d01/ex2/ex2.py Executable file
View file

@ -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()