General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 12 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 12 of the Advent of Code - https://adventofcode.com/2022/day/12
14 REPLIES 14
DawnDuong
13 - Pulsar
13 - Pulsar

D12 reminds me of another path-finding question in last season, and this is when we start to explore the limit of Alteryx as a "pseudo programming language", I think.

I think the method I used is closest to the "Breath-First Search (BFS)" algorithm (TBH when I did the workflow I did not know this is called BFS). This algorithm is considered greedy and probably is the reason it took 16.8 seconds to run Part 1 but a whopping ~50min to run part 2 on my laptop (Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz 2.59 GHz, 8GB RAM). There is definitely a more efficient BaseA solution and I look forward to see the solutions by the wizards amongst us :-)

Spoiler
Main
DawnDuong_0-1670833178522.png

 

Part 1 macro
DawnDuong_1-1670833200249.png

Part 2 macro (which uses part 1 macro)

DawnDuong_2-1670833239875.png

 

DawnDuong
13 - Pulsar
13 - Pulsar

Inspiration struck when I was having dinner with my husband... so I flipped the workflow to a reverse Dijkstra and voila both part 1 and part 2 finished together in 40 seconds. See hint in the spoiler 😎

Spoiler
Nothing fancy. I just flipped the methodology to go from E to S (instead of going from S to E). Both part 1 and part are now on the same order of magnitude. In fact, Part 2 finishes faster than part 1 in this reverse Dijkstra method because the termination happens earlier as part 2 terminates at either S or a whereas Part 1 only terminates at S.
DawnDuong_0-1670845394943.png

 

patrick_digan
17 - Castor
17 - Castor

It took a couple tweaks to keep the macro from blowing up the count.

Spoiler
I just go from one spot to the next and found a couple ways in the macro to keep the record count down. First I implemented a second iterative part by reading and writing to the same file. This helps prevent it from visiting the same spot twice. I also added in a unique in the macro to again prevent going to the same spot.

Workflow:
patrick_digan_0-1670855583229.png


Macro:

patrick_digan_1-1670855694260.png

 

Jean-Balteryx
16 - Nebula
16 - Nebula

Day 12 done ! ✔️

 

It's not pretty, it doesn't even fully work, but it gives the solution ! 👌

 

Workflow

 

Spoiler
JeanBalteryx_0-1670855782983.png

Macro

 

Spoiler
JeanBalteryx_1-1670855806345.png
AkimasaKajitani
17 - Castor
17 - Castor

I finishes today'ss challenge using Breadth First Search algorithm. Today, I didn't have a concentable time because of my work. As a result, I did this challenge after the work.

 

 

Spoiler
The difference between part1 and 2 is only input data. So I use the same macro in part1 and 2.
AkimasaKajitani_1-1670861092712.png

Macro:
AkimasaKajitani_2-1670861115527.png

 

 

 

 

 

mmontgomery
11 - Bolide

Not an easy one and h/t @patrick_digan 's solution for removing already-seen paths, which was my main struggle.

Spoiler
Built out the relationships using the formula tool for adjacent points and find/replace to map the current point position to adjacent points. The final part was adding interface tools to the macro to pick row/column. To find matches, I did a regex count matches of "," to an additional macro output that wrote out each relationship on each iteration. Since the removing matches was part of a file that read/wrote to itself, it was run once initially then disabled when the macro was run.

P1/P2 difference was changing the "start -change value here" filter before the macro
mmontgomery_0-1670866311007.pngmmontgomery_0-1670866987471.png

 

 

clmc9601
13 - Pulsar
13 - Pulsar

Thankful for @patrick_digan 's hint about keeping rows from exploding. My original solution was very close but couldn't keep the row count small enough.

 

Spoiler
It took me a while to understand why the unique worked. Turns out, it doesn't matter *how* the path reached any given location, as long as it did so in the same number of steps as another path variation. Then, you only need one of those path variations. 

Workflow:

Screen Shot 2022-12-12 at 5.22.46 PM.png

Macro:


Screen Shot 2022-12-12 at 5.11.34 PM.png

 

Pang_Hee_Choy
12 - Quasar

thankful for @patrick_digan for the tips. 

Spoiler
workflow:
Pang_Hee_Choy_0-1670920730587.png

macro:
add a message tool as a stopper when have a solution.

Pang_Hee_Choy_1-1670920755710.png

 

 

JarekSkudrzyk
11 - Bolide

thank you for the tips - I have used Djinkstra with slight modification and finally managed to solve the issue

Spoiler
JarekSkudrzyk_0-1670922187531.png

makro:

JarekSkudrzyk_1-1670922261443.png

 

Labels