Advent of Code 2022 Day 19 Walk-Through

preview_player
Показать описание

Please attempt the problem on your own before watching this video!

Рекомендации по теме
Комментарии
Автор

Cool! My solution was pretty slow - about 1 hour for Part 2. But adding 2 tricks from your video improved it to about 3 seconds. Thank you so much!

learning_with_rj
Автор

Nice, thanks for the video! You guys do much better than me. Still, as a note, my optimization was this: Once I had recipes with 2 genodes, I discarded all without genodes. Once a genode producer in any recipe, I also discarded recipes without genode producing robots and few obsidian.

szieberth-adam
Автор

One performance improvement I made, which made a lot of difference is before checking the cache, whether the state to evaluate is actually more valuable than the max valuable state already evaluated for that minute. You only need an array of size max_minutes to store the max visited state. A state can never be more valuable if the projected value for any kind of material is not > than the max value already evaluated.

bikkel
Автор

The optimization for not building extra bots can be improved from bots[i] < maxspend[i] to bots[i] * time < maxspend[i] * time - amt[i]

For my C++ solution, this reduces the time for P2 from ~6-7s to ~300-500ms so it is definitely impactful.

hyper-neutrino
Автор

for Part 2 this solution in python for me hardly ever finishes, definitely more than 3 minutes - 5minutes, I didn't wait.
1st optimization is the direct creation of robots
2nd optimization is to not build excess robots

With the above part1 runs in 7 seconds but part2 runs more than 2 minutes.

bladekiller