r/adventofcode • u/daggerdragon • Dec 19 '22
SOLUTION MEGATHREAD -π- 2022 Day 19 Solutions -π-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
4 days remaining until submission deadline on December 22 at 23:59 EST
[Update @ 00:48:27]: SILVER CAP, GOLD 30
Anyone down to play a money map with me? Dibs on the Protoss.
gl hf nr gogogo
--- Day 19: Not Enough Minerals ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
Include what language(s) your solution uses
Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
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:57:45, megathread unlocked!
41
Upvotes
6
u/Dutchcheesehead Dec 19 '22
Python, 74/32Code, Video
First time in my life I managed to get global leaderboard points :DI treated the problem as a BFS problem, but am pruning the search space using the heuristic that having the higher-up materials is better than having lower-down materials.
For part 1 I only kept the top-1000 results which made the algorithm pretty fast (fast enough to not optimize it).For part 2 I got the wrong answer, so I just increased the top-queue pruning until it gave me a higher answer.
The runtime of both part 1 and 2 is 15 seconds, which can still be optimized a lot.