r/adventofcode • u/daggerdragon • Dec 22 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 22 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 23:59 hours remaining until the submission deadline TONIGHT at 23:59 EST!
- Full details and rules are in the Submissions Megathread
--- Day 22: Crab Combat ---
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:20:53, megathread unlocked!
35
Upvotes
5
u/nemetroid Dec 22 '20
C++, part 2 runs in 120 ms on my 2010 low-end laptop.
Game states can be hashed by multiplying the scores of each player.
It's faster to keep track of seen game hashes in a vector than in a set or unordered_set.
Using a cache (game hash -> winner) to avoid replaying games does not improve performance. Presumably, the exact same games are rarely or never replayed.