14 lines
288 B
Python
14 lines
288 B
Python
|
from functools import reduce
|
||
|
from operator import add
|
||
|
|
||
|
def converge(fuel):
|
||
|
ff = (fuel//3)-2
|
||
|
if ff <= 0:
|
||
|
return 0
|
||
|
else:
|
||
|
return ff + converge(ff)
|
||
|
|
||
|
with open('input', 'r') as f:
|
||
|
result = reduce(add, [converge(int(line)) for line in f])
|
||
|
print(f"{result}")
|