Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2022 Day 17 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team
Discussion thread for day 17 of the Advent of Code - https://adventofcode.com/2022/day/17
8 REPLIES 8
mmontgomery
10 - Fireball

Took too long cause of tedious bugs/minor mistakes, but, got P1.

Spoiler
Step 1: Set up a base case with an iterative macro to write to the initial and base file for find/replace
Step 2: Configure I-Macro to loop until rock steady state
Step 3: Run batch macro to loop through groups until I hit 2022
mmontgomery_1-1671331376974.pngmmontgomery_2-1671331400536.pngmmontgomery_3-1671331455401.png

 

 

clmc9601
13 - Pulsar
13 - Pulsar

This challenge would be much easier with a more flexible object than a dataframe (tabular rows/columns). It took me a long time and multiple attempts to arrange my data to even start the calculations.

 

Spoiler
On my first attempt, I stored the cumulative tallest heights for each of the seven x values. Turns out, this doesn't account for lower cavities in the rock stack that can still fit more rocks. I had to redesign my solution to allow for this.

Attempt 2 was spatial, but then I realized it's challenging to shift an entire polygon left or right. You can convert the SpatialObj to a string, but ONLY with a Select tool. This solution might have worked if I could manipulate the points using regex and string parsing functions in a formula tool. Since I needed a multi-row formula tool with multiple shifting evaluations inside it, the Select didn't cut it. Thankfully, I could create a similar outcome using a field with cumulative rock stack coordinates.


Main workflowMain workflowIterative macroIterative macro
For part 2 hint and workflow:

Spoiler
There's a pattern after so many loops of the initial jet stream instructions. You don't need to model all trillion rocks. Find the pattern after several repeats of the initial jet stream, then you can calculate the tower height after a trillion rocks.

Screen Shot 2022-12-19 at 7.12.16 PM.png

AkimasaKajitani
17 - Castor
17 - Castor

Finally, it is done. It took too much time for P2.

 

Spoiler
It took 3:27 for part1 and 21min for part2.

AkimasaKajitani_0-1672809510677.png

Part 1: I only simulate the rock and jet.
Part 2: Of course I can't fall a trillion blocks!! So, I falled 6000 blocks to find the pattern. I took some sample(100 samples) which should contain the rock pattern and the height diff from previous height and match it from the 6000 blocks results in Matching macro.  In my case, after falling the 2439 blocks the diff of the height pattern is repeated each 1700 blocks.
I didn't try to shoten the workflow running time, but I once found the pattern, so I can optimize the workflow to shorten the running time.


Part 1 TETRIS macro : only simulate the rock and jet.

AkimasaKajitani_1-1672809600088.png

 


Part 2 Matching macro : This macro is only finding the pattern.
AkimasaKajitani_2-1672809727603.png

 

 

patrick_digan
17 - Castor
17 - Castor

Took awhile to solve part 2, and I generated way too many records to make sure I captured the pattern. I also spent some time optimizing my macro only to realize that it took the exact same amount of time...

Spoiler
patrick_digan_0-1672836312479.png


patrick_digan_1-1672836344508.png

 

 

Pang_Hee_Choy
12 - Quasar

duplicate reddit python, take few hours to understand it.

link: adventofcode/17b.py at main · tmo1/adventofcode · GitHub

Spoiler
part1: replicate
part2:
check by duplication on each rock.

1. modified part 1 to output following. 
     - rock count
     - highest y in 7 column
     - rock type
     - jetID.

Pang_Hee_Choy_0-1673441183980.png

2. adjust all y by minus the lowest value (now the pattern is standard to compare)
3. compare x1-x7 + type + jetID, remain any have same pattern (pick 1, it have alot)
4. calculate the cycle of rock and Y, and adjust the value near to 1 trillion.
5. fill in the variance to 1 trillion rocks. (continue the step based on jetID until rocks is fulfil.)
    a. get the jetID, and use it as start point (data from part1),
    b. add variance to rock get from a
    c. get new jetID and use it as stop point.
    d. get different Y between a and c.
    e. add it to 4.


 

SeanAdams
17 - Castor
17 - Castor

Welll this took WAY longer than expected - this is just part 1.

Turned out that I'd made a few simple mistakes - and found them eventually by going back to the info provided on part 1 - and breaking down EVERY SINGLE move into test cases, and comparing them to mine.     The problem turned out to be using base 0 numbering, but getting the mod wrong....

 

Spoiler
This is really 3 parts:
a) Figure out the shapes, and get them into Row/Col format
b) figure out how to move a shape left / right and down (the shape mover)
c) an iterator to go through each shape and to iterate through each new shape.


SeanAdams_0-1673802179234.png

I've not done a big writeup here - will do this once I finish part 2




SeanAdams
17 - Castor
17 - Castor

I feel you @mmontgomery  - same here!

SeanAdams
17 - Castor
17 - Castor

OK - after getting done with Part 1 - part 2 came quickly.

 

Notes within

 

Spoiler
So - part 1 gives you the base set of data to look at to figure out Part 2.
The trick here is to see if there's some pattern where the same shape occurs with the same step in the wind cycle.     Fortunately, with this data there is a pattern (but that was not necessarily a given - it's part of the way that the data was created).

So - look at the part 1 data to see how many rocks it takes to repeat the same wind; for the same shape
Once you have this - you can then look the height which is added with each such cycle

You can then figure out how many of these cycles fit into the target number (the 100xxx number) - and the remainder - the remainder, you just look at that iteration / rock height from part 1.

SeanAdams_0-1673827740495.png

 

Labels