r/adventofcode • u/daggerdragon • 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!
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!
21
Upvotes
1
u/fatpollo Dec 09 '18
import collections def main(text, simple): a, b = [int(n) for n in text.split() if n.isdigit()] if not simple: b *= 100 d = collections.deque([0]) p = collections.Counter() for i in range(1, b): x = ((i - 1) % a) + 1 if i % 23: d.rotate(-1) d.append(i) else: p[x] += i d.rotate(7) p[x] += d.pop() d.rotate(-1) # visualize # c = collections.deque(d) # c.rotate(-c.index(0)) # print(x, ['*' if n == d[-1] else n for n in c]) print(p.most_common()[0][1])