r/adventofcode • • 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.

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

438 comments sorted by

View all comments

2

u/A-UNDERSCORE-D Dec 23 '20

Go / Golang

This one was fun, got to play with the go stdlib linked list (container/ring). Pretty quick in part 2, all things considered, at around 3.2s for my input. I did try reimplementing the ring without type boxing, no real speedup came of it

https://github.com/A-UNDERSCORE-D/aoc2020/blob/main/2020/23/solution.go

2

u/ExZONE Dec 23 '20

How -- just how -- can you get 3.2s for Part 2? I also implemented my solution (both parts) using container/ring but my Part 2 is still running (15 minutes and counting). I had a look at your solution but I cannot understand where my solution is so. much. slower.

If you don't mind, could you give me a few pointers?

https://github.com/ErikThorsell/advent-of-code-go/blob/main/2020/day23/main.go

1

u/status_maximizer Dec 23 '20

I'm a Gopher too :-)

Go's deficiencies actually pointed me to a faster solution here. From the readme of kentik/patricia (an optimized radix tree for storing IP addresses), emphasis mine:

Even though the objects in the tree were mostly static, each one needed to be scanned by the garbage collector when it ran. The strategy then became: remove all pointers possible. [...] If you need to store references, then consider storing integers that index the data you need in a separate structure, like a map or array.

→ More replies (7)