Discussion thread for day 8 of the Advent of Code - https://adventofcode.com/2023/day/8
I feel "Day5 comes again!". I created WF that I will never look back again😂
Part2 was tough again.
Today was terrible... very challenging, wasted a lot of time expecting a large answer for Part 1, so I wasted an extra couple hours there. I did finish though, which is good. I also learned a few things along the way, which is even better!
Workflow - Day 8Macro for part 1Macro for part 2
- Simple parsing.
- Part 2 macro is an update on 1, to do a join and amend the logic to search for ending letters.
- Needed to use other methods *cough* to find the LCM but knew that was the approach so looped through each starting value, but should really have put this in a batch macro. So will need to check out @CoG LCM macro.
my last bit for part 2 isn't dynamic, and thank goodness for AMP which went much faster.
P1 was easy enough brute force. P2 in spoiler
Interesting puzzle! Frustrating to solve, but I learned a lot This takes longer to run than I would like, but it's manageable.
I'd actually love to revisit this one sometime when I'm fresh to optimize my approach. Lots of food for thought with this puzzle without completely wrecking my brain like Day 5 did.
Part 1: Brute force. Traverse every node based on the input directions until I hit ZZZ. Used an iterative macro.I was proud of my formula to evaluate which direction to follow for each iteration: Mod([Engine.IterationNumber],Length([Source_data]))Macro:Part 2: Per usual, I tried to brute force this and felt really good about my logic... until I saw it creeping up to 500k iterations. It was sometime around then that I not only knew there had to be a mathematical solution, but that I'd have to figure it out in order to solve the puzzle. This workflow would never finish running otherwise.After some rubber ducky debugging, I remembered something about Least Common Multiples from elementary school math and went to work. This is, I'm sure, far from the most efficient solution, but here's how I did it:
Batch Macro:
Iterative Macro:
Whole Workflow:
I'm still finding AoC fun but it's getting a little wild! Part 2 had me researching math algorithms...
Special thanks to @estherb47 for an old thread on [redacted]
Day 8 done! Part 1 and 2 macros look so different as I had stupidly been generating the instructions within the iterations for part 1 and changed that for the second part. Like others, I just ran each 'A' instance one-by-one using a batch macro that wrapped the path iterator, then took the LCM for the answer. A very fun one today!
The last part of part. 2 I didnt do in Alteryx, but inserted the numbers into a LCD Calculator 😅.
What a challenge...
With the hint from @Mukai.
Full transparency, I needed a little help from reddit to understand how to solve part 2 without having my macro run for days:
My solution. Macro over macro over macro...
Not sure if there is a better way, but at least I got the answer!
I cheated a bit on this one and did the last bit of part 2 manually using this LCM site.
Had to think through this one and analyze the input data to find patterns.
@Laurap1228 Oop, thanks for the hint! As I was brute forcing my way through the problem, I ended up trying the LCM tool and it worked 😱
There is a trick to day 8 - read below.
My solution.
LCM macro : At the past Weekly challenge, we made the GCD macro. At that time, I made LCM macro using that GCM macro. I used this macro for this AoC.
ooops posted Day 9 in Day 8 (haven't solved part 2 yet)
edit: so I gave in and caved to the LCM calc as well. I really didn't pay attention to this part until i'd wasted days "If only some of the nodes you're on end with Z, they act like any other node and you continue as normal."
and was convinced I could calculate row by row
I definitely took some notes to get this one done. I was proud of getting Part 1 on my own but needed helps on part 2. Finally got there!
Had to fight through a ton of brain fog due to illness to get through this one. From the beginning, my processes were correct and I had really tiny errors throughout, which were ultimately cleared up by re-reading the challenge approximately 3 million times.
Because it was taking me so much time, I was able to optimize for speed and play with about 65 billion different versions of my macros. The attached workflow takes 1 minute to run with AMP enabled.
Moral of the story: Take great caution when Alteryxing when you haven't been able to eat or drink sufficiently.
I post again with solution in yxzp.
Started off Part 1 thinking it was going to be breeze... and it would have been if I would have built my macro without any errors. After spending an embarassing amount of time on my macro and it still not working, I decided to take the second example and manually run each iteration of my macro by changing my inputs to the outputs I created and increasing my iteration number manually. It only took my three iterations to find my error -- my formula needed a = instead of a > ">😐
Now that it's already December 22 and I'm not even halfway through, and since everyone already posted how difficult Part 2 is, I'm going to go ahead and stop right here and move on to Day 9.
Macro:
Done