r/adventofcode • • Dec 09 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 9 Solutions -🎄-

--- Day 9: Marble Mania ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 9

Transcript:

Studies show that AoC programmers write better code after being exposed to ___.


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 00:29:13!

22 Upvotes

283 comments sorted by

View all comments

Show parent comment

3

u/K_05 Dec 09 '18

Using a deque is pretty smart (and holiday spirit!). I did something similar, but instead of just returning max(scores.values()), I set it to a variable, and have it loop for marble in xrange(last_marble + 1, (last_marble * 100) + 1) again because the game is just being continued for part 2 and then returned both maxes. It's not as flexible/ modular, but it's how I initially saw the problem, and probably less time, since it doesn't need to recalculate.

8

u/[deleted] Dec 09 '18

The calculation of part 1 is maybe 1% of the overall time the program runs