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 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

80 REPLIES 80
PangHC
13 - Pulsar

no macro. let see how many days challenge can solve without macro

Spoiler
Screenshot 2024-12-02 143104.png
cgoodman3
14 - Magnetar
14 - Magnetar

I went down the rabbit hole with part 2!

 

Spoiler
Does it count not using a macro when you hard code a batch 😜
 

Screenshot 2024-12-02 063349.png
Ignoring the bad res. 

Part 1 was simple, but I got caught out where the total number of levels could be different for each record in the real data.
Part 2, I spend so long trying something based on what I had done in part one of identifying if each row was an increase or decrease on the previous, going with complex multirows. For example IF Decrease but previous row was an increase, change to increase if the next row - previous row is actually an increase <=3... But my brain wasn't working.
In the end went down the batch macro route, but also couldn't work out if I need a batch or iterative, so just hardcoded the logic of skipping layers and calculating if all increasing or all decreasing.

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
LHolmes
9 - Comet

Well I feel like the heat turned up a little bit... 😅

 

Spoiler
2024 Day 2 Part 12024 Day 2 Part 1
2024 Day 2 Part 22024 Day 2 Part 2
Tokimatsu
12 - Quasar

I solved it, but it is an uncool workflow.

Spoiler
スクリーンショット 2024-12-02 154702.png

gawa
16 - Nebula
16 - Nebula

Tool Golf for Part2 without Macro. Another fun of AoC is refining WF which I believed it was the best at that time.

Spoiler
Trick here is to create all patterns that miss one level by combo of the Generate Row tool and the Regex_Replace function.
By doing so, the logic is almost same as part1. Difference is only to exclude duplication of report.
image.png
Overall WF for Part2
image.png
rbgruwel
8 - Asteroid

Used an iterative macro, does not yet deserve the beauty prize. But it works.

 

Spoiler
Example.png
danboll_life
9 - Comet

lacks versatility

Spoiler
AoC_2024_02.png

 Continue Filter...

cgoodman3
14 - Magnetar
14 - Magnetar

With a bit of thinking time I've come up with my attempt at tool golf.

 

Spoiler
In the bottom half I create a look up table  for all substitution sequences.

e.g. 
1,2,3,4,5
1,3,4,5
1,2,4,5
1,2,3,5
1,2,3,4

Then transpose this like with the initial dataset, then with a join I get all possible outcomes so only need to evaluate once.  Then it's a case of filtering only for the first pattern for part 1 and including all for part 2.

Screenshot 2024-12-02 093010.png
Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
DataNath
17 - Castor
17 - Castor

Certainly won't be winning any awards for elegance but work calls and 2 stars = 2 stars. Definitely lured into a false sense of security yesterday!

 

Spoiler
Day 2.pngDay 2 Batch.png

Macro is just a copy and paste of the main workflow, removing one record at a time from sequences that failed the initial part 1 ask and checking for compliance against the new allowance.

 

Spainey
9 - Comet

Took a lot longer than yesterday, but I got there after I gave up refusing to use a macro on Day 2. 

Spoiler
My workflow:
AoC 2024 Day 2.png
I used the RegEx tool to Tokenize the data to Rows (which initially tripped me up on Part 1 as I assumed that all numbers in the sequence were a single digit). An Order column was added so I could easily identify and remove the first number in the sequence and could determine the State (increasing/decreasing) of the other numbers. I concatenated the State and then used a formula to remove duplicate strings in order to then identify those that were deemed SAFE.

The formula below identifies and removes duplicate strings in a comma separated string array. 

IF !IsEmpty([Concat_State]) && Contains([Concat_State], ",")
THEN REGEX_Replace([Concat_State], '(\b[^,]+)(?=.*, *\1(?:,|$)), *', '')
ELSE [Concat_State]
ENDIF​


For Part 2 - I wrapped the above logic into an iterative macro, where I removed the row corresponding to the current iteration (+1 as it is 0-based index) and redefined the Order column.

 
and the macro:
AoC 2024 Day 2 - Macro.png

 

 

Labels
Top Solution Authors