2019: d01: ex2: add solution
This commit is contained in:
parent
6a00802583
commit
c4fa0cbc6a
15
2019/d01/ex2/ex2.py
Executable file
15
2019/d01/ex2/ex2.py
Executable 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()
|
Loading…
Reference in a new issue