General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 16 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 16 of the Advent of Code - https://adventofcode.com/2022/day/16
5 REPLIES 5
SeanAdams
17 - Castor
17 - Castor

Lovely day for a depth-first search.

 

I originally thought I was going to have to figure out how to do simulated recursion by mocking up a call stack, but it turned out to be a bit easier than I thought.    Fully brute-force depth-first search with a filter for paths that don't seem worthwhile

 

Spoiler
So - this is mainly a DFS - and the algo is roughly:
on each iteration:
....Bring in a list of all the valves with the current score for that valve so-far, its open/close status, and whether there is a person at that valve.
- Work out the starting score for this round by adding in the flow for all open valves
- Multiply this out, once for possible move:
      - possibly open the valve
      - move via a tunnel to valve x
      - move via a tunnel to valve y
- Remove anything but the highest scoring 5000 routes
- Make the updates for these moves - leaving you with a set of boards (one row per valve)
.... iterate

Parse:
Very simple parse phase
SeanAdams_0-1672626541364.png

 

Main flow:
This calls the parser, the working stage and then summarizes 

SeanAdams_1-1672626586907.png

The data set structure for the iterations is fairly simple:

SeanAdams_2-1672626666416.png

 


You can see from the algo above - that each iteration you just add on sets of data like this for each board / node on this depth first search.

The Tree Search
SeanAdams_3-1672626772998.png

 



AkimasaKajitani
17 - Castor
17 - Castor

Finally, it is done.

 

Spoiler
Part 1: It took 10 minutes to get the answer at my workflow. I shortened the route not using rate 0 valve route.
Part 2:  @SeanAdams 's hints are very helpful for me on the part 2. It is too large records to get the answer. So I limited to the 5000 records follow the hints.
Anyway, I can't use part logic because of an elephant, so I re-made the part 2 macro.

AkimasaKajitani_0-1672746502303.png


Macro for shorten the route

AoC_2022_16_2.png

Macro for part 1

AoC_2022_16_3.png


Part 2 macro:

AoC_2022_16_4.png

I made the visualization about this sample data using Network Analysis tool. The node size is related to the rate size.

AoC_2022_16_1.png

 

Spoiler
The workflow is as following.
AoC_2022_16_6.png

This is the visualization of my input data.
AoC_2022_16_5.png


 

 

clmc9601
13 - Pulsar
13 - Pulsar

Turns out my P2 just needed a small adjustment. Took me several weeks to figure it out!

 

Spoiler
Workflows posted on GitHub

Part 1: iterate through the minutes and track the cumulative route and cumulative pressure released

Screen Shot 2023-01-03 at 4.23.51 PM.pngScreen Shot 2023-01-03 at 4.45.16 PM.png

Part 2: same thing but give the option to skip through valves with low pressure without opening them. Adding the "keep top X routes only" from @SeanAdams did the trick. I'm still evaluating why it didn't find the max pressure when I ran it in 4 hours with all combinations but did find the max pressure with only top 2000 routes...

Screen Shot 2023-01-03 at 4.55.50 PM.png
patrick_digan
17 - Castor
17 - Castor

Brute force with one critical assumption.

Spoiler
I just went down all the paths, but only saved the top 10,000 paths based on the total pressure released. There is nothing magical about 10,000. The number has to be big enough to capture the final best path, while small enough to allow alteryx to process in a reasonable amount of time. The "solution" that pops out can't be too high, but it's possible it's too low if not enough paths were used.

Workflow:
patrick_digan_0-1672835423801.png


Macro:

patrick_digan_1-1672836112705.png

 

Pang_Hee_Choy
12 - Quasar

same concept.

Spoiler
part 1
Pang_Hee_Choy_1-1673251767927.png

 



part 2
ensure it cover all 4 situations. then nothing different.
A open B move
A move B open
AB open
AB move

Pang_Hee_Choy_0-1673251740875.png

 

Labels