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

Function play

2018/src/09.py:5–15  ·  view source on GitHub ↗
(players: int, rounds: int)

Source from the content-addressed store, hash-verified

3from collections import defaultdict, deque
4
5def play(players: int, rounds: int) -> int:
6 marbles, scores = deque([0]), defaultdict[int,int](int)
7 for i in range(1, rounds+1):
8 if i % 23 == 0:
9 marbles.rotate(7)
10 scores[i % players] += i + marbles.pop()
11 marbles.rotate(-1)
12 else:
13 marbles.rotate(-1)
14 marbles.append(i)
15 return max(scores.values())
16
17@aoc.main('09')
18def main(indata: str) -> tuple[int,int]:

Callers 1

mainFunction · 0.85

Calls 1

rotateMethod · 0.80

Tested by

no test coverage detected