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

Function part2

2018/src/07.py:11–25  ·  view source on GitHub ↗
(reqs: dict[str,list[str]])

Source from the content-addressed store, hash-verified

9 return ans
10
11def part2(reqs: dict[str,list[str]]) -> int:
12 left, working, t = sorted(reqs.keys()), dict[str,int](), 0
13 while left:
14 for c in list(working.keys()):
15 working[c] -= 1
16 if working[c] == 0:
17 working.pop(c)
18 left.remove(c)
19 for x in left:
20 if x in working or any(r in left for r in reqs[x]):
21 continue
22 if len(working) < 5:
23 working[x] = ord(x) - 4
24 t += 1
25 return t-1
26
27@aoc.main('07')
28def main(indata: str):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected