r/adventofcode • u/daggerdragon • Dec 23 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 23 Solutions -🎄-
--- Day 23: Category Six ---
Post your full code solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
- Include the language(s) you're using.
(Full posting rules are HERE if you need a refresher).
Reminder: Top-level posts in 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's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 22's winner #1: "Scrambled" by /u/DFreiberg
To mix one hundred trillion cards
One-hundred-trillion-fold
Cannot be done by mortal hands
And shouldn't be, all told.
The cards make razors look like bricks;
An atom, side to side.
And even so, the deck itself,
Is fourteen km wide.
The kind of hands you'd need to have,
To pick out every third,
From cards that thin and decks that wide?
It's, plain to say, absurd!
And then, a hundred trillion times?
The time brings me to tears!
One second each per shuffle, say:
Three point one million years!
Card games are fun, but this attempt?
Old age will kill you dead.
You still have an arcade in here...
How 'bout Breakout instead?
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
Message from the moderators:
Only three more days to go! You're badass enough to help Santa! We believe in you!
View all comments
Show parent comment
2
u/fizbin Dec 27 '19
Comments:
queuemodule which I found useful in other days' problems (e.g. day 7, which I also did with threads) and so used for this day as well; however, on this problem it's something of a wash - it might save you a bit of time on working out fine-grained locking, but the one global lock you use here is more than good enough for the problem. (And there's a subtle issue to avoid with getting the X coordinate of a point and then -1 because the thread putting the point in didn't get both coordinates in yet.)isQueueEmptyasall(not x for x in self.queue)