In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2025 Day 2 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

49 REPLIES 49
TheOC
16 - Nebula
16 - Nebula

Trying to hold off using a macro until at least day 4. Let's see how that pans out.

Spoiler
TheOC_0-1764692235458.png

 

Cheers,
TheOC
Connect with me:
LinkedIn Bulien
Raj
16 - Nebula

the one Without Regex 

DataNath
17 - Castor
17 - Castor

Can never complain with a bit of RegEx! A nice day 2.

 

Spoiler
Workflow.png
DylanBell
10 - Fireball

Took me longer than I'd care to admit, a good reminder to make sure your string fields are long enough for your inputs!


Bulien
Goddenra
8 - Asteroid

I could have tidied up Part 2 with a macro, but I didn't.

Not pretty. Some elegant solutions using Regex I need to check out. 

Spoiler
Screenshot 2025-12-02 164146.png
Pilsner
13 - Pulsar

This one was more of a thinker for me. Took a little while to figure out what I even wanted to do, but it wasn't too bad to actually build after that!

Spoiler
Here's my full workflow:
Pilsner_0-1764692039950.png



Part 1:

1) The first steps were relatively straightforward as I used a text to columns and a generate rows to create one row per "potential ID", based on the ID ranges provided in the input.

Pilsner_4-1764693783341.png

 



2) Potentially an unnecessary extra but I created a copy of the ID column but this time stored it as a string, so I didn't need to keep changing the datatype.

Pilsner_5-1764693804536.png

 



3) At this point, I simply extracted the left half and right half of the string separately. I was able to do this by simply taking the length of the string and dividing it by two. Then feeding it into the Left / Right functions.

Pilsner_6-1764693876512.png

 



4) I filtered to the cases where the left and right halves were equal, then summed the values. 

Pilsner_7-1764693895990.png

 



Part 2:

Step one and two were the same as in part one, but then things did differ slightly. 

1) The key difference between part one and two, is that the "repeated" string could be of any length. However we can deduce, in order for a string to be classed as repeated, it must appear at least twice, hence the length of the repeated pattern cannot exceed, half the length of the overall string. i.e

- If we look at ID 123123, we know that the "repeated string" has to be at most, 3 characters long, (a "repeated string" of 4 characters, would create an answer 8 character long, when repeated, therefore would not work for this example)
- "1", "12", and "123", are the only 3 we need to consider

To consider these cases in isolation I needed one row per case, so I used the generate rows to create these extra lines (counting up, until I got to half the length of the original string):

Pilsner_1-1764693096094.png


2) Now I could create the the potential "repeated strings",  on their separate lines, by using the Left() function. Then replaced all occurrences of the "repeated string" in the ordinal ID column, with nothing. If the cell in the ID columns was left completely blank, then I knew the pattern must have repeated throughout the whole ID. Using the same example as before I would get the following.

ID Repeated String (aka "Substring") ID after Replacement  
123123 1 2323  
123123 12 33  
123123 123   < - Nothing remaining therefore the ID must have contained the repeated string (and nothing else)

 

Pilsner_2-1764693494058.png

 



3) Finally it was a simple case of filtering to the IDs, that resulted in an empty "Replace" column, then summing a unique list of their values.

Pilsner_3-1764693589887.png

Edit: If I were to go back and redo the question, having seen other peoples solutions, I would like to use the regex "\1$". It appears to represent one repetition of the group previously defined. I'd never seen it before today so thanks all for the new regex trick!

mceleavey
17 - Castor
17 - Castor

Suspiciously straightforward...

 

Spoiler
mceleavey_0-1764694149583.png

I first used Text to Columns to split on the comma, then split to rows on the dash. I then generated rows between the two parts of the ID:

mceleavey_1-1764694223536.png

I then used some sexy Regex to identify first matches of two characters, then two or more:

mceleavey_2-1764694270660.png

Then simply summed the IDs for each match.

 Whenever I do the first couple of days quickly I feel it's written specifically to hurt me.

 

M.



Bulien

jrlindem
12 - Quasar

I, like others, found this challenge to be easier mentally to figure out than Day 1, but I could see where others might disagree.  It's a different skillset to solve this than the first day's.  Anyway...

 

Here’s my solution:

 

Spoiler
jrlindem_0-1764696692488.png

 

Narrative:

 

Spoiler

It was easy enough to parse the data, splitting it by comma, then by the dash.  From there, filling in the ranges, etc.

 

Task 1:  It dawned on me pretty quickly that odd numbers wouldn’t satisfy the pattern, so I used Mod() to get rid of those, then simply split the string in half using the string length and compared the first half to the second half.  Easy enough.

 

Task 2:  Turns out my regex skills aren’t as creative as others.  With the helpful hint that people were using Regex, I did some research and found a suitable solution to identify the Invalid ID’s.

 

An alternative that I considered was just splitting the string, which had a max value of 10 into separate streams and then rejoining them towards the end.  The auspice of building out that many tools seemed like more work than exploring the Regex, so that’s the route I went in the end.

And now back to the breathing easy, waiting until Day 3.  Cheers, -Jay

OllieClarke
16 - Nebula
16 - Nebula

As @PhilipMannering famously said "RegEx is the sex"

Spoiler
A single character difference between part 1 and part 2Day 2.png
OllieClarke
16 - Nebula
16 - Nebula

@mceleavey 

Spoiler
the regex_match() function will always compare the entire string to your RegEx, so you don't actually need the ^$ wrappers in your RegEx. Could reduce your typing by ~30%!
Labels
Top Solution Authors