2018/Day08/Day8A.py

11 lines
280 B
Python
Raw Normal View History

2018-12-08 22:31:29 +00:00
def read_node(it):
child_count, meta_count = next(it), next(it)
child_sum = sum(read_node(it) for _ in range(child_count))
own_sum = sum(next(it) for _ in range(meta_count))
return child_sum + own_sum
it = (int(x) for x in input().split())
print(read_node(it))