We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 6 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

24 REPLIES 24
Hub119
11 - Bolide
11 - Bolide

Was too tired to post this in the wee hours of the morning when this FINALLY finished running... if I don't sleep, why should my computer be allowed to? (Note: this took even longer than it needed to as I FORGOT to disabled my computer's ability to go to sleep after set intervals until part way through... Part 1 runs in a couple seconds at least... doing so thousands of times however for part 2...)

Spoiler
WorkflowWorkflow







Iterative Movement MacroIterative Movement Macro




Batch MacroBatch Macro
DaisukeTsuchiya
14 - Magnetar
14 - Magnetar

I spent a long time for P2 but finally my WF can run in 23 sec for P1 and P2.
I got the idea from @gawa to avoid nested macro.

Spoiler

スクリーンショット 2024-12-08 072039.png
<P1 Macro>
スクリーンショット 2024-12-08 072142.png
<P2 Macro>

スクリーンショット 2024-12-08 072216.png
I use spartial tool for debugging.
スクリーンショット 2024-12-08 073715.png
ntakeda
12 - Quasar

My solution...

I went on a trip, and by the time I came back, the answer was output (it took about 3 hours).

Spoiler
2024-12-08_12h27_54.png

PangHC
13 - Pulsar

part 1: 2 mins > 9 seconds

part 2: 12 hrs > 1hrs > 10 mins


python take 15 seconds without any optimise, but alteryx is take forever, so it may a good to use python sometimes. to reduce the run time.

 

Spoiler
part1: loop by 1 step (2 mins for 5k+ loops) > loop until it reach the block or out of map (9 seconds, for 160+ loops)
from here can see the macro is take long time to loop. 

part2: use output from part1 (9 seconds * 5k = 12hrs~), logically, i don't run for it.

to reduce to 1hrs
1. log the path, so can have earlier escape when have same path appear.
2. start from the block -1 steps (so it not waste time to run until the new block, i.e. it not take 160 loops to go to last points)
3. split to 4 for AMP engine
Spoiler
iterative macro
Screenshot 2024-12-09 110011.png

to reduce to 10 mins
1. rework the nest macro, since part 2 no longer require record the maps, hence
    a. keep the block ("#") only for (reduce the memory and data size to speed up)
    b. just join by x/y and identify the if there have any block in front of the direction, if have turn 90 degree, if no, it is out of map.
    (by change these method, it reduce half of tools)
2. use summary to count, instead of record count tools
3. split to 4 for AMP engine

workflow:Screenshot 2024-12-09 105937.png
batch macro
Screenshot 2024-12-09 105947.png
nested macro
Screenshot 2024-12-09 105954.png

 

 

Tokimatsu
12 - Quasar

Not smart, but it worked.

Spoiler
スクリーンショット 2024-12-10 102002.png

lwolfie
11 - Bolide

Missed posting my solution for part 1.  Things are getting busy, so I'm not sure how much further I'll get this year.

aiahwieder
9 - Comet

Stuck on 1 star again . . . sometimes you just gotta roll along!

Carolyn
12 - Quasar
12 - Quasar

Ugly but got the job done! Part 2 took 1 hr, 47 min to run. 

 

Spoiler
For Part 2, I created a Nested macro where I looked at each of the 5k squares that my guy steps in. I then basically said "if in square #1, he runs into a new obstacle and can't go to square #2 and instead turns to the right, will that new path be a loop?" I ran that new path through an iterative macro for a bunch of iterations (since the guard had the audacity to create a loop with more than a rectangle's worth of points - basically I wanted him to keep going until he went off the map. Then I knew it wasn't a loop). Once that point was done, I then said "if in square #2, he runs into a new obstacle" and just repeated. 

Workflow: 
2024-12-10_17-00-34.png

Part 1 macro:

2024-12-10_17-00-46.png

Part 2 macro - Outer macro (should've been a Batch but I did it as Iterative)

2024-12-10_17-01-52.png

Inner macro: 

2024-12-10_17-02-08.png
SeanAdams
17 - Castor
17 - Castor

This is the beginning of the days where the runtime is horrendous - this one took multiple hours to run.

 

 

Spoiler
OK - how to approach this?
- Part 1 was an iterative macro - which passes on the iteration
     - The grid, flattened into 1 row
     - the current positoin
     - the history of where I've been so that I can check for loops
- Part 2 then took the walk history from part 1 and checked each of these one by one to see if changing it to a blocker would cause a loop - I couldn't come up with a better way to do this quantitatively - I suspect that there's a smaller subset to check by just looking at where the same point is crossed multiple times, but not tested this idea.


Part 1:
Data prep was pretty large because on each iteration I'm packing and unpacking from the call stack (serialize / deserialize)
 

image.png

then the grid walker macro has this same complexity, both on the inbound and oubound side.
You'll also see that I have different outputs - one to track each position visited, one for the iteration, one if a loop is detected etc.
image.png





Part 2:
Part 2 is slow but not hard - all you do is use a batch macro to try each block once - and because the batch macro doesn't remember anything, it's much much simpler.

image.png
You can see that part 2 calls the part 1 grid walker for each new attempt.

This is very very slow - not proud of the speed, but it works :-)


Here's the python solution

image.png
image.png
 

image.png


All solutions at SeanAdams10/AdventOfCodePython: Advent of code challenges in Python - across multiple years



 

 

SeanAdams
17 - Castor
17 - Castor

For everyone who has a working solution - esp @gawa and @CoG and @mmontgomery and @DataNath  - have you run procmon to see what Alteryx is doing that causes it to run in such a long runtime compared to doing this in code.     This is the key to helping Alteryx to optimize the power of macros.     this is my next task for day 6, to figure out what's causing the run-time difference.

For example: 
- Day 6 part 1 in Alteryx with AMP turned on (multi-threaded): 1m48 sec (yes - I am a bit bashful since others have done part 1 so quickly)

- Day 6 part 1 in code: 0.012 seconds on a single thread

that's a factor of 9000x.    Even taking some of the faster runtimes posted by folk (like 1 sec or so) - that's still a factor of 100 difference with very heavy optimization

 

so there's something going on in each of our machines that is generating workload for the PC which may not be needed - this may be a really valuable example for us to dive into as a group to see if we can spot what's happening and create a few ideas on the community to performance tune macros.

 

here's a guide for how to get started with ProcMon:
https://chatgpt.com/share/6759637c-7fb0-8007-a05f-bfd08f0557f9

 

 

Labels
Top Solution Authors