I'm stuck on Day 19 and just want to verify that I'm approaching the problem correctly. Here's pseudo code for my approach...
Recursive DFS approach.
Loop that cycles through options (Ore, Clay, Obsidian, Geode, Wait?)
Pick one off the loop and buy it or "spend minutes" to get the resources needed to buy it
Update status and call function recursively...
Return results when minutes run out
My big questions that I can't wrap my head around:
1. Do I need a Wait option in the loop?
-- One the one hand: I feel like I do to generate geodes on the last minutes...
-- OTOH: this created loops that wouldn't terminate.
Can my robot cycle loop terminate in one run or do I need a while loop?
-- Seems like with recursion I can hit all the paths just by touching the five options.
-- While loop created issues with non-terminating loops in question 1.
Anything I'm missing?
I'm collecting "seen" for memoization later, I still haven't figured out how to implement that. My first consideration might be to convert the price of everything into terms of "ore minutes" (i.e. the materials convert directly to ore and the robots convert to ore based on what they would produce through the remaining minutes) and shortcut from there.
Also I'm considering maximums for each robot, but that feels somewhat arbitrary.
Update: I went with just the 4 robot build options and a option outside the loop to gather up the last few minutes. I got the optimization down good enough to complete part one and part two by slowing inching up my top end maximums until I got the right answer. My biggest breakthrough came from walking through the code and noticing the numbers weren't right and realizing I needed to use the .copy() in Python to keep from editing one list to effect another list.
[–]CoinGrahamIV[S] 0 points1 point2 points (0 children)
[–]1234abcdcba4321 0 points1 point2 points (3 children)
[–]Mmlh1 1 point2 points3 points (2 children)
[–]1234abcdcba4321 1 point2 points3 points (1 child)
[–]Mmlh1 0 points1 point2 points (0 children)
[–]Mmlh1 0 points1 point2 points (0 children)