Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from collections import deque
- with open('9.txt', 'r') as file:
- data = file.readline()
- m = re.match(r'(\d+)\D+(\d+)', data)
- players, last_marble = int(m[1]), int(m[2])
- PLAYER_NUM = players
- LAST_MARBLE = last_marble * 100
- marbles = deque([0])
- scores = [0] * PLAYER_NUM
- for marble in range(1, LAST_MARBLE+1):
- if marble % 23 == 0:
- marbles.rotate(7)
- scores[marble % PLAYER_NUM] += marble + marbles.pop()
- marbles.rotate(-1)
- else:
- marbles.rotate(-1)
- marbles.append(marble)
- # print(marbles)
- # print(players)
- print(max(scores))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement