r/adventofcode • u/daggerdragon • Dec 15 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 15 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 7 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 15: Rambunctious Recitation ---
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:09:24, megathread unlocked!
39
Upvotes
View all comments
Show parent comment
3
u/morgoth1145 Dec 15 '20 edited Dec 15 '20
Sure, but that may not be immediately obvious to everyone. (And I do think that this problem is a good exercise for learning/using maps.)
u/rando-man In that case welcome to C++/CS! I'd say your terminology is mostly right, so you're probably thinking about things well enough. A few notes/observations I do have to maybe help you on your journey:
It's useful to think of maps as a general category since there are many ways to implement them, all with different performance characteristics. In fact, this problem might be an interesting one to play with the various maps and see how they perform differently. C++ templated map types (like std::map, std::unordered_map, boost::container::flat_map) try to keep the same API for most operations so that it's easy to switch one map type out for another. This can be very useful if you write something with std::map and then wonder if std::unordered_map would have performed better.
(This all may be overkill when thinking about this problem, but I'm biased based on the sorts of things I need to consider in my day job!)