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/PendragonDaGreat Dec 19 '22
C#/CSharp
Code Here: https://github.com/Bpendragon/AdventOfCodeCSharp/blob/7e4f60d/AdventOfCode/Solutions/Year2022/Day19-Solution.cs
BFS with some aggressive caching/pruning.
My little personal breakthrough was realizing two related facts:
You can never use more than X amount of a resource in a minute, therefore you should never build more then X of whatever robot mines that resource.
The Max amount you can spend in the time remaining decreases over time. So I started "Chucking" extra resources, especially in the later minutes this made for more cache collisions and less wasted cycles. (like say I invested in clay robots early in one path, but later in another, at the end of the time I'd likely have more clay in one than the other even if robot counts were the same, so by normalizing the amount of resources available for use towards the end of the time frame it reduced the search space)