ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2025 Day 5 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

Discussion thread for day 5 of the Advent of Code - https://adventofcode.com/2025/day/5

41 REPLIES 41
DataNath
17 - Castor
17 - Castor

A very nice day 5! Took me a little to realise the quirks of part 2 and ended up creating a disgraceful Multi-Row Formula expression but hey, 2 stars = 2 stars.

 

Spoiler
Workflow.png
aiahwieder
9 - Comet

Part 2 almost broke me (and by "me" I mean the computer) until I realized

 

Spoiler
there's a way to do it without Generate Rows!
NaiLo
8 - Asteroid

Part 2 is always the brain twist,

Spoiler
 I really wanted to make it work with Generate Rows but alas, way too big of a memory suck
mkeiffer
11 - Bolide
11 - Bolide
Spoiler
Screenshot 2025-12-07 at 5.21.09 PM.png

My Day 5 solution! 

martinson
11 - Bolide

Woop

Spoiler
martinson_0-1765199828005.pngmartinson_1-1765199838030.png

 

Cheers,
martinson

LinkedIN

Bulien
estherb47
15 - Aurora
15 - Aurora

First challenge where I created several "this approach doesn't work" containers. Those were on my work computer, so this is the cleaned up and working version

Spoiler
estherb47_0-1765245700023.png


First part was very easy. Love the Between function!!

For the second part, I realized that generate rows would take too long (mistake made solving part 1), so figured I'd have to create groupings of the numbers

First approach, I used multi-row to find the first number in a range, and the last number. But that wound up not working. User error and zero energy to debug

Figured what was really important was the ending value of the group, so for all numbers that roll into the same grouping just got a group number. End number updated row by row. Min start number on the group, and max end number. Difference + 1 and then na grand sum.

Samantha_Jayne
Alteryx
Alteryx
Spoiler
AOC - Day 5.png
Samantha Clifton
Alteryx
#alteryxrocks
mceleavey
17 - Castor
17 - Castor

Oh, I was lucky I remembered this from a few AoCs ago...

 

Spoiler
mceleavey_0-1765447226089.png

In Part One I simply split the data into fresh ranges and available ingredients, fed the available ingredients into a batch macro using the ranges as control parameters:

mceleavey_1-1765447576809.png

I then simply used a formula to be overwritten by each range and determined if each available ingredient was within those ranges ([Ingredients] >= [Fresh Ingredients 1] and [Ingredients] <= [Fresh Ingredients 2]).

For Part Two I was very lucky that I remembered this very puzzle from AoCs of the past. I immediately knew the generate rows was going to liquify my PC and I remembered the method to this was to simply create overlapping batches, so if you sort ascending by the lower end of the batch, then by the top end you get to a position where you can determine the bottom end of a batch and the top end of the batch below, thus creating a continuous number until there is no overlap, whereby the batch starts anew. 
To achieve this I spent far too long getting a simple multi-row formula to work because I have that brain thing.
The first is as follows:
IF [RecordID]=1 THEN [Fresh ID 2]
ELSEIF [Fresh ID 2]<=[Row-1:Max Fresh ID 2] THEN [Row-1:Max Fresh ID 2]
ELSE [Fresh ID 2]
ENDIF

This basically determines if top end of the current row is below the one above, which means it's subsumed by the previous batch, or if it is higher, so take the current row max. This is important as the next step will use this to determine the "batch" into which it fits:
if [RecordID]=1 then 1 elseif
[Fresh ID 1]<=[Row-1:Max Fresh ID 2] THEN [Row-1:Batch]
ELSE [Row-1:Batch]+1
ENDIF
So, if the top of current row was selected it moves into the next batch, and if not it is part of the batch above.
For example, in the following ranges you can see the first range and the second range do not overlap:

mceleavey_0-1765448492864.png

This means the top of the range for each remains the same and they belong in different batches.
However, in the following example you can see that row 7 at least partially overlaps with row 6:

mceleavey_1-1765448637939.png

...and so rows 6 and 7 are the same batch.
Once I had this it was a simple task of grouping each batch and taking the min start point and max end point giving me a full range of numbers. One minus the other gives me the amount of different numbers (plus one...yes, it took me longer than I'd care to admit to missing that), then sum the amount.

 



Bulien

locateparcels
5 - Atom

Nice breakdown! I found that visualizing the stack movements step by step really helped me understand Day 5’s BaseA style logic. Once you treat each move as an independent operation and track the changes in a table, it becomes much easier to verify the result.

Desmond
9 - Comet

Day 5 solutions.

Labels
Top Solution Authors