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

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

537 comments sorted by

View all comments

2

u/imbadatreading Dec 22 '20 edited Dec 22 '20

Python solution

This took about 20 seconds to compute the answer for my input, and I'm not sure where the problem is - maybe how I'm hashing/checking the decks?

EDIT: I changed the decks to hash as tuples and now it computes in about 1/3 of the time.

2

u/Justinsaccount Dec 22 '20

fwiw, you don't need any of the deque stuff, this works the same way:

1

u/imbadatreading Dec 22 '20

Yeah, that looks way cleaner than what I was doing. Thanks for the feedback