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
????.?#? | 3,2 |
Configuration | Count | Remaining Characters |
????.?## | 1 | 6 |
????.##. | 1 | 5 |
ID | Prior Count | ||
1 | 1 | ????.? | 3 |
2 | 1 | ????. | 3 |
We repeat the process from step 1 (hence the dynamic part of DP algorithm), to get:
ID | Prior Count | Remaining Characters | ||
1 | 1 | ?###.. | 3 | 1 |
1 | 1 | ###.. | 3 | 0 |
2 | 1 | ?###. | 3 | 1 |
2 | 1 | ###.. | 3 | 0 |
ID | Prior Count | ||
1 | 2 | ? | - |
2 | 2 | - | - |
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.
1 | count |
##.##? | 1 |
##..##? | 1 |
.##.##? | 1 |
1 | count |
##.##? | 3 |
2 | new_2 |
1,1 | #.# |
1,4 | #.#### |
1 (trimmed ".") | new_2 | text before ? | new_2 (same text length with text before ?) | result |
##.##?? | ##.##.# | ##.## | ##.## | pass |
##.##.? | ##.## | ##.##. | ##.## | pass |
##.#.? | ##.## | ##.#. | ##.## | fail |
@Pang_Hee_Choy Great thinking man
spent a huge time on this Challange but never thought this way.
P1 solved with no macro. P2, well, probably will need some help.
@Pang_Hee_Choy - 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 :)