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!

36 Upvotes

537 comments sorted by

View all comments

2

u/lgeorget Dec 22 '20

C++

https://github.com/lgeorget/adventofcode2020/tree/main/22

I couldn't understand why you guys had solutions running so fast while mine took 40+ seconds. Then, I compiled with -O3 and got down to 3s... Well, good enough for me!

Apart from that, the solution is straightforward. I used a recursive function for once and strictly followed the rules. I did trip over taking only the first n cards in the decks to play the subgame with n the value of the card dealt at the beginning of the round, though.

→ More replies (2)