Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 2 (BaseA Style)

MeganBowers
Alteryx Community Team
Alteryx Community Team

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

74 REPLIES 74
gawa
16 - Nebula
16 - Nebula

It's time to use Macro but not Iterative one yet.

Spoiler
Part1: Put flag as per this expression, and concat flag for each report.
image.png
We need to know the number of records which is '+++++' or '-----' so apply Regex_Match() function, and count the True record. 
*we need to escape meta character like '+' by '\' 
image.png
Part2: Basically the same logic as Part1 was applied. Difficult point was how to prepare all pattern that miss just one level.
I go with Batch Macro; 1st batch=remove 1st level, 2nd batch=remove 2 level....
Of course, the outcome contains duplicated Report so count distinct by Summarize tool.
image.png
geoff_zath
Alteryx
Alteryx

Messy solution without a macro!

Spoiler
AoC_2024_day2.png

CoG
14 - Magnetar

Updated x2 (Tool Golf/Optimized version V4):

Spoiler
Main V4.png
To accomplish a 6 Tool solution, the Generate Rows Tool is quite the monster, utilizing a 2D matrix loop to accomplish what the Text to Columns/RegEx Tool would have. Not quite as elegant, but a stroke is a stroke. A very elegant 7 tool solution can be achieved with very reasonable formulae.

Updated (Tool Golf/Optimized version V3 - elegant)

Spoiler
Main V3.png
I am quite pleased with the elegance and simplicity of this solution.

Main V3 Formula.png

 

Updated (Tool Golf/Optimized version V2):

Spoiler
Main V2.png
Achieves both Part 1 and Part 2 using 9 tools (per part). Multi Row Formula Tool requires some extra logic to make this work:
Main V2 Formula.png

 

(My Original Solution) No fancy macros from me yet:

Spoiler
Main.png
For part 2, I joined the output of part 1 with main data to identify "Unsafe" reports that could benefit from the dampener, then I applied the exact same logic as Part 1 after dampening (Generate rows to brute force)

 

ScottLewis
11 - Bolide

Day 2 was a nice case of ugly solutions that work. Considered a batch macro but chose to brute force it rather than fiddle with inputs.

The trick is 

Spoiler
Creating all of the possible iterations of set - 1 row. You can do this for the maximum length set (8 in my case) since you're going to have to sum away duplicates anyway.
My version had a small hiccup in that I was throwing out row 1 (which is always safe but has an extra case on the change calculation. 
In Part 2 that is only right if you aren't working on the iteration that doesn't have row 1, so you need to do Min(Row) instead of Row1.

 
 
Day2Scott.PNG

Hub119
11 - Bolide
11 - Bolide

Why sleep when you can earn AoC stars after midnight? 😀

Spoiler
AoC D2 Pic.png
AkimasaKajitani
17 - Castor
17 - Castor

My solution!

 

Is today really the second day?

 

Spoiler
image.png
kelsey_kincaid
12 - Quasar
12 - Quasar

This one definitely challenged me more than I expected for Day 2. The concepts felt straightforward, but my execution was... not. I found myself reworking the logic several times. I have the feeling there's a more straightforward approach, but my tired brain couldn't find it today. Hoping to revisit this one!

 

Spoiler
2024_Day2_KelseyKincaid_MainWorkflow.png2024_Day2_KelseyKincaid_Macro.png
One of my gotcha's was the way I handled the change in value for the first value in the multi-row formula. I also mishandled situations where the change was neither an increase or a decrease. Lots of little pieces of logic to think through in this one!
kelsey_kincaid
12 - Quasar
12 - Quasar

@gawa Your solution is so elegant! Thank you for sharing

DaisukeTsuchiya
14 - Magnetar
14 - Magnetar
Spoiler
スクリーンショット 2024-12-02 153023.pngスクリーンショット 2024-12-02 153058.png


 

Labels
Top Solution Authors