Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 22 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

15 REPLIES 15
CoG
14 - Magnetar

Good break from Day 21. Pretty much just brute force (just need to read thoroughly to ensure that all logic is captured):

 

Spoiler
Part 1 is entirely brute force. I set up an iterative macro that runs n=2000 times (Numeric Up Down Interface Tool), Formula Tool handles evolution steps (make sure you use the right values since the first calculation for each part doesn't actually update the secret, but creates a temp value for further calculations that do change the secret):
Evolve Secret.png

Part 2: I modified the first macro to output all evolutions of price for each buyer, generating about 4M records. Multi-Row Formula Tool for the win here. We can use it to calculate the price change, then another one to generate all sequences of 4 consecutive price changes, then index all sequences so that we can isolate only the first occurrence of each sequence for each buyer. From there, we just need to filter off later occurrences and Summarize to identify the total price/# of bananas we can expect to trade for each sequence. Identify the maximum value for the answer!
Get Prices.png 

Main Workflow:
Main.png 

 

ScottLewis
11 - Bolide

A nice clean day after a dirty awful yesterday in which I left my workflow running overnight and came back to a finished not the answer.

 

This one highlights the things Alteryx is good at. Multi-row formulas and summation allow you to shortcut things that most (other) programming languages would find syntactically complicated.

 

Spoiler
The math is just math. If it is giving you trouble, do it in steps, one formula per step. This one lends itself to the one big formula approach because of how nested the explanation is. 

Generation of secret numbers is a clean iterative macro case. Shows off how you should make things like the number of steps an input to make it easier to find the terminal condition and so you don't have to go in and out of the macro for testing.

Part 2 macro modification was just adding a third output that kicked every row rather than just the last one and putting on an ID before sending it into the macro. At this point I should really just be in the habit of doing that anyway in case part 2 needs it. RowID passing through the macro is pretty low cost.

Part 2 logic is interesting. Don't often get to stack two multi row formulas followed by two summations. Here they are calc change, calc sequence, Find first sequence and summarize price by sequence. Then you just sort and you're done in time for tea.

If you wanted to get fancy you could go straight to sequence by embedding the definition of change at each step of the sequence formula but the result would be a case study in how not to write formulas.
AkimasaKajitani
17 - Castor
17 - Castor

Solved!

 

The question was difficult to understand, but today is straightforward!

Spoiler
Part 1 is simple. Just build the logic as described in the problem statement. It was helpful to have all the output for debugging purposes and Part2.

For part 2, I can easily find the answer by generating patterns with the Multi-Row Formula tool and summarize the number of bananas for each pattern. Note that a pattern may match multiple times for each buyer, but this is only used for the first pattern.

AoC_2024_22_05.png
macro
AoC_2024_22_02.png

 

kelsey_kincaid
12 - Quasar
12 - Quasar

This was a breath of fresh air, besides me spending an hour troubleshooting the fact that I only ran 1,999 iterations instead of 2,000 after reworking for P2 😅

Spoiler
2024_Day22_KelseyKincaid_wf.png
2024_Day22_KelseyKincaid_Macro.png

 

 

 

DaisukeTsuchiya
14 - Magnetar

It’s not a particularly difficult problem as long as we correctly understand the problem statement.

 

Spoiler

I struggled a bit to fully grasp the problem statement, but for P1, I followed the instructions, created the formula in the Formula Tool, and ran the loop 2000 times to get the answer.

For P2, I used a multi-row formula tool to calculate the patterns and aggregated the first digit of the price that matched the pattern for each record. Initially, I overlooked the part about "the first price that matches the pattern" and ended up confused when my answers didn’t match.

スクリーンショット 2024-12-22 182736.pngスクリーンショット 2024-12-22 182815.png

mmontgomery
11 - Bolide
11 - Bolide

Day 22. More in spoiler

Spoiler
P1: Iterative Macro to loop through combos
P2: Take ones column for each row of P1 I-Macro and output it. Then second macro to get pairings of four by using range of iteration +1 to interation +4. Group the categories and sumD22_P2_Macro.pngD22_P1_Macro.pngDay22_Workflow.png
Hub119
11 - Bolide
11 - Bolide

This was a wonderful reprieve from the nightmare that is day 21 lol.

Spoiler
WorkflowWorkflow
Spoiler
MacroMacro
Goddenra
8 - Asteroid

Made for Alteryx this is. Enjoyable one today!

leozhang2work
10 - Fireball
Spoiler
day 22 - 1.pngday 22.png

Finally a chill day

Labels
Top Solution Authors