Discussion thread for day 12 of the Advent of Code - https://adventofcode.com/2023/day/12
Macro for part 1. Faster of the two ways I was able to solve part 1 (the other being constructing all possible sets of operational springs up to len(springs-damaged). Runs in about 3 seconds on my Part 1 data. Bursts in to flame if I feed it 10 lines of part 2. Working on that. Probably something to do with partial search or excluding cases but I haven't cracked it yet.
@ScottLewis 3 seconds? that is supper fast. mine spends 3 minutes... 😂Part2 is disaster..
Phew, Finally got part 2. I solved part 1 with a much different mehtod, but it didn't scale for part 2. So now this method solves either part. "Only" 28 seconds for part 2!
This took me so long, and I'm honestly a little bitter about how simple the workflow looks, now that I've tidied it up. It was so satisfying watching the journey from basically crashing my computer, to running part 2 in ~6 seconds. I'll post my workflow when 10 people have finished the D12P2.
Edit: Posted my Workflow
We repeat the process from step 1 (hence the dynamic part of DP algorithm), to get:
Data Prep (Standard Macro):
Iterative Macro:
I haven't gotten Part 2 yet, but I don't know that I will today so I'll go ahead and post my Part 1. It isn't the most efficient solution, but there are components of it that I'm proud of. Just need to optimize!
struggle a lot...
thanks AMP to speed up the time spend.
@PangHC Great thinking manspent a huge time on this Challange but never thought this way.
P1 solved with no macro. P2, well, probably will need some help.
@PangHC - Thanks for sharing! I was stuck on how to come up with all the diff possible combos for Part 1 and your solution was super straightforward. I was trying to do it all at once but duh, do it one at a time
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 check5. Reduce the number of records by grouping and summing countsThis 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.