Join the Inspire AMA with Joshua Burkhow, March 31-April 4. Ask, share, and connect with the Alteryx community!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 5 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 5 of the Advent of Code - https://adventofcode.com/2024/day/5

39 REPLIES 39
DaisukeTsuchiya
14 - Magnetar
14 - Magnetar

Day 5 P2 was an challenging task for me. Regarding P2, I referred to  @Samantha_Jayne 's workflow. Her workflow was truly outstanding and something I couldn't replicate.

Spoiler
My workflow isn't smart, but I settle for it as it is.
スクリーンショット 2024-12-06 052923.png

 



Ccraig6
6 - Meteoroid

This was a tough one.... the way i did it for P1 wouldnt work for P2 so need to rethink design.

Spoiler
Day 5.jpg
JeffF
Alteryx
Alteryx
Spoiler
Very messy with nested macros, but it worked.

Day05-JeffF.png
Day05-IterativeMacro-JeffF.png
binuacs
21 - Polaris
Spoiler
image.png
Qiu
21 - Polaris
21 - Polaris

@Samantha_Jayne 
This is so elegant. Thank you for sharing.
I went to complete oposite direction as Max Macro, Batch + Iterative.
I have downloaded your flow for leaning.
AoC is all about the logic, I guess.

Qiu
21 - Polaris
21 - Polaris

@Samantha_Jayne 
Can I have a question about your flow?
The questions states below


(47 doesn't necessarily need to be immediately before 53; other pages are allowed to be between them.)

But in your "Rule in Input" variable, it appears that your assume that the pages are always immediately next to each other.
I did run my data, and your workflow is actually giving the correct answer.
I am really wondering why. can you enlighten me? Thanks.
2024-12-06 093533.png

Samantha_Jayne
Alteryx
Alteryx

Sorry spoilers and I can't put it in a box on my phone!!

 

From memory, not in front of my computer and I promised I would write it up properly as it was a bit of a genius mind this morning that I'm not used to.

 

So I've appended all the possible combinations using the append tool.

 

Then I know how many matches are required per group to ensure that I have all the pages. Calculated in the formula tool.

 

Find the combination with all the matches, then count the middle option for them.

 

I was surprised it worked too. Hope that helps.

Samantha Clifton
Alteryx
#alteryxrocks
kelsey_kincaid
12 - Quasar
12 - Quasar

Finally got this one figured out! 

 

 

Spoiler

I solved Part 1 by checking each page number in the update against each rule relevant to that page number, and comparing the index of one against the other.

 

I got extremely stuck on Part 2, and didn't have time to give it much thought before tonight. Luckily, I think the mental break is what I needed. I realized that I don't actually need to reorder anything, I just needed to identify which element was in the MIDDLE. Luckily, every instruction set had one page number that by definition had to be in the middle!

 

I'm eager to see everyone else's elegant solutions, and to give thought to reworking this one. This wasn't my favorite but it was a good challenge.



2024_Day5_KelseyKincaid_Macro.png2024_Day5_KelseyKincaid_WF.png

 

 

 

LHolmes
9 - Comet

This was a lesson in walking away and coming back with fresher eyes. Sometimes it helps to stop and ask - what do I really need to do here.

 

Alas - no fancy macros or iterations. The result may not be completely robust but it got the job done.

 

Spoiler
2024 Day 5 Part 12024 Day 5 Part 12024 Day 5 Part 22024 Day 5 Part 2
Carolyn
12 - Quasar
12 - Quasar

Solved! For Part 2, I was struggling with how to proactively figure out the right order. After futzing with it for awhile, I gave up and went with an iterative macro inside of another iterative macro.

 

In the inner iterative macro, I started at the left of each "update" and checked to see if page 1 and page 2 were in a good or bad order. If bad, I switched. If good, I left alone. Then I checked if the entire line was resolved. If not, I checked page 2 against page 3. And then for any where I got to the end and they still had problems, I sent them back through the inner iterative macro, and just repeated until they were in the right order. 

 

Definitely not the most efficient way to solve it, but the entire workflow runs in 3.1 seconds so I'm calling that good enough :)

 

Spoiler
2024-12-06_16-24-55.png

Outer macro:

Macro 1.png

Inner macro:

2024-12-06_16-25-18.png

 

Labels