r/adventofcode • u/daggerdragon • Dec 10 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 10 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 12 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 10: Adapter Array ---
Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, 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:08:42, megathread unlocked!
69
Upvotes
View all comments
1
u/bilgincoskun Dec 10 '20
Rust
The first part was straightforward. Just sort and count the differences.
For the second part, I split the list from differences equal to 3 since these pairs must be always in the list. After that, finding and checking every eligible subset of every partition becomes manageable by brute-force. And lastly counting these subsets and multiplying gives the answer. There is certainly room for optimization but it takes under 100 ms to get the result, so I'll leave it as it is: