-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09.py
34 lines (29 loc) · 804 Bytes
/
09.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from lib import *
input = read_input(2018, 9)
players, n = map(int, re.match(r"^(\d+) players; last marble is worth (\d+) points$", input).groups())
lst = deque([0])
scores = [0 for _ in range(players)]
for i in range(1, n + 1):
p = i % players
if i % 23:
lst.rotate(-1)
lst.append(i)
else:
lst.rotate(7)
scores[p] += i + lst.pop()
lst.rotate(-1)
print(max(scores))
players, n = map(int, re.match(r"^(\d+) players; last marble is worth (\d+) points$", input).groups())
n *= 100
lst = deque([0])
scores = [0 for _ in range(players)]
for i in range(1, n + 1):
p = i % players
if i % 23:
lst.rotate(-1)
lst.append(i)
else:
lst.rotate(7)
scores[p] += i + lst.pop()
lst.rotate(-1)
print(max(scores))