Python has a super-powered C doubly linked list built in, so I feel like I'm totally cheating here, but:
from collections import deque
def get_sequence(max, players):
sequence = deque()
scores =  * players
for marble in range(0, max + 1):
if marble % 23 == 0 and marble > 0:
current_player = marble % players
scores[current_player] += marble + sequence.pop()
with open('input.txt', 'r') as f:
for line in f:
players, last_marble = [int(n) for n in re.findall(r'\d+', line)]
scores = get_sequence(last_marble, players)
large_scores = get_sequence(last_marble * 100, players)
When I was whiteboarding this out, I was noticing a mathematical pattern. Didn't fully go down that road, but I'd be super interested to see if someone did this using arithmetic instead of a linked list.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.