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

Function part2

2018/src/12.py:16–25  ·  view source on GitHub ↗
(transitions: set[str], pots: set[int])

Source from the content-addressed store, hash-verified

14 return sum(pots)
15
16def part2(transitions: set[str], pots: set[int]) -> int:
17 seen = set()
18 for n in range(1,1000):
19 pots = step(transitions, pots)
20 minpot = min(pots)
21 pattern = tuple(sorted(p - minpot for p in pots))
22 if pattern in seen:
23 return (50000000000 - n) * len(pots) + sum(pots)
24 seen.add(pattern)
25 assert False
26
27@aoc.main('12')
28def main(indata: str) -> tuple[int,int]:

Callers 1

mainFunction · 0.70

Calls 1

stepFunction · 0.70

Tested by

no test coverage detected