r/adventofcode • u/daggerdragon • Dec 23 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 23 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
Submissions are CLOSED!
Thank you to all who submitted something, every last one of you are awesome!
Community voting is OPEN!
42 hours remaining until voting deadline on December 24 at 18:00 EST
Voting details are in the stickied comment in the Submissions Megathread
--- Day 23: Crab Cups ---
Post your code solution in this megathread.
Include what language(s) your solution uses!
Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks.The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
2
u/rdubwiley Dec 24 '20 edited Dec 24 '20
Here's my somewhat slow solution in Python3
It's using a cup class that works like a linked list which are then stored in a dictionary by their value to allow quick lookups. The search for the next cup could probably be faster by calculating the next directly rather than running a loop running through them. Pretty fun puzzle.
Another trick to consider is that you don't actually need to store which cup is in which index at each point (as both just needs the relative positions from cup 1).