MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / node_value

Function node_value

2018/src/08.py:17–21  ·  view source on GitHub ↗
(e: Tree)

Source from the content-addressed store, hash-verified

15 return sum(e[1]) + sum(metadata_sum(c) for c in e[0])
16
17def node_value(e: Tree) -> int:
18 cs, data = e
19 if len(cs) == 0:
20 return sum(data)
21 return sum(node_value(cs[c-1]) for c in data if 0 < c <= len(cs))
22
23@aoc.main('08')
24def main(indata: str) -> tuple[int,int]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected