Discussion thread for day 12 of the Advent of Code - https://adventofcode.com/2023/day/12
Finally finished D12P2. As 2 days has already passed, I upload my WF this time.
@Pang_Hee_Choy - Thank you so much for sharing super straightforward your solution.
I was stuck for so long time then I can get idea from your spoiler although I didn't download your WF.
Finally I can finished after repeating debugging so many times. WF runs in 15 sec.
I can sleep tonight.
I struggled with Day12P2 but I finally got the second star!!!
I did not notice that the RegEx Match expression in a macro gave up to run, so it took me for long time.
Part 1 macro : simple macro
Part 2 macro:
In part 2 macro, I made it according to following term.
1. I convert rom ? to . and #
2. Create a definitive pattern on my own & delete the left-most number if it is already definitive.
3. Re-create Num.
4. Discard those that don't fit in the pattern check
5. Reduce the number of records by grouping and summing counts
This workflow takes 1 minutes to finish.
This is one of those days where it started out with brute force, and then Part 2 showed me the error of my ways.
It’s now running part 2 in ~17 sec – very happy with this solution!
Solution:
A few things that will help you as you think through this:
So here’s the recipe:
Parse the data
Figure out valid combinations:
Repeat until you run out of strings with ? characters:
This works fast for a few reasons:
Just one summarize tool in one place made it dramatically faster. I can't tell you how long it took me to do that.