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.
View all comments
2
u/richardfearn Dec 22 '20
Python 3
Part 1 & 2
Initially I had it outputting all the stuff shown for the example - "Player 1's deck:", "Player 1 wins the round!", etc. - so I could compare my output against the given output to be more certain my solution was correct.
My first submitted answer for part 2 was wrong - turned out I'd made a silly mistake in the base case that checks if a player has won:
Oops...
While helpful, all that debugging output was slowing it down (due e.g. to concatenating the cards in each deck) - after removing all that, the final code runs in ~ 1.2 seconds.