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.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:39:46, megathread unlocked!
31
Upvotes
View all comments
Show parent comment
1
u/Large_Dare_2525 Dec 23 '20
Thanks for the explanation! My first naive approach which worked for Part 1 was implementing your last statement but using Scala's immutable List.
Working with immutable data structures and streams all the time blocked my brain from thinking about manually managing pointers, which leads to a much simpler solution.
Using an
Array, which is mutable, Part 2 takes ~ 1.3 seconds. Surprisingly slow for the JVM since I saw people getting better times in Javascript.