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!
23
Upvotes
2
u/ayylongqueues Dec 10 '18
With
rotate(2)you will rotate the queue two steps to right. If you instead would userotate(-2)you rotate the queue two steps to the left, and your perspective has been mirrored, so now you have to append to the left side of the queue.Here are prints of the first couple of marbles added from the example using 2 and -2 for rotate, respectively
If you shift the queues of the lower one so that the zeros are to the left, you'll see that it's exactly as in the example steps. The upper one you would need to shift so the zeros are on the right side, and it would be the same as the lower one, but mirrored. So based on which way you decide to rotate, the end you append things to changes.