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

50 REPLIES 50
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

I tried with multiple Generate Rows tools for Part 2, and then learned RegEx solution from the Community. Thanks!

Spoiler
Workflow
AoC_2025_Day2_workflow.png
Erin
11 - Bolide

Already a break from macros on Day 2? Is this normal? 

Spoiler
So jumping to part two, can't wait to look back through other's posts to see if anyone else also did count matches and filtering route, and curious what other sleeker ways there are of doing this (mine is anything but dynamic and won't work for IDs with length over 10, but that was the max length that I had in my input dataset).

I broke this up into single, double, triple, fours and fives (because I can't remember what the proper term is for fours and fives - listen English is hard). I did a regex replace and in hindsight a left formula would have worked just fine. I also could have combined my count match and my regex replace formulas. Oh well. Will chalk that up to extra typing experience. So I then counted how many times that pattern repeated in the ID which by itself wouldn't work - which is where all the filtering comes in next.
formulas.png

So for my filters, I first checked to make sure the length was evenly divisible by my pattern with the mod formula (so in the example I'm looking at fives), and that it repeated an even number of times without leftovers length/count match = 5 and then I also wanted to make sure that the length was greater than 5 to bein with. In hindsight, this is probably overkill. Lets chalk it up to being extra careful because I was too trusting yesterday and it burned me. 
filters.png

My filter for checking if it was the same number for all the characters was a bit different. It was for length > 1 and where count single = length. 
Then I unioned my trues and summed them up! Bingo Bango - doneskies! 
Erin
11 - Bolide

Ok looked through some of the other comments and learned that I've barely even scratched the surface on my regex journey! As I'm working on these, the "Make a man out of you" song from Disney's Mulan keeps playing in my head - but instead AoC will make a coder out of you (me?)....

oh now that song's in your head too? You're welcome 😊

Desmond
9 - Comet

Day 2 was a little easier than day 1 but I went the long route to get the second part of the answer, regex was helpful but could have done it with complex left and right formulas too.  

Tokimatsu
12 - Quasar

I felt Day 2 was easier than Day 1.

Spoiler
I generated all the numbers I needed to check using row generation. However, there should also be logic to generate only the necessary numbers, so I'd like to create that workflow later as well.

スクリーンショット 2025-12-03 100204.png



AkimasaKajitani
17 - Castor
17 - Castor

My solution!

 

At first, I went to the no regex route.

Spoiler
After the 1st solution, I made regex solution. The regex route is really time effective! So I was shocked!!!
But I didn't know this regex, so I learned a lot from this problem. 

AkimasaKajitani_0-1764725129122.png

 

kelsey_kincaid
12 - Quasar
12 - Quasar

I really liked this one! A nice change of pace versus yesterday.

 

 

Spoiler

Always "fun" to play with RegEx
Day2.png

danboll_life
9 - Comet

It looks like my cat walked over the keyboard.

Spoiler
danboll_life_0-1764727949549.png

 

PangHC
13 - Pulsar
Spoiler
PangHC_0-1764732950480.png

 

estherb47
15 - Aurora
15 - Aurora

Oh my, this day was a fun one. I read part 1 to be what was supposed to be solved in part 2, so went back on my logic a few times. Also learned some new things about RegEx along the way.

 

Spoiler
Same initial steps of parsing on the comma, and then using Generate Rows to find all of the in-between numbers. I am LOVING GetLeft, GetRight, GetPart. Thanks, @NicoleJ !!

My first thought was I needed to generate all of the patterns that might be repeated. One character, two characters, three characters, etc.

So, I used Generate Rows to generate a field for "number of characters in a string that must be repeated" from 1 to half of the length of the number itself. Let's call this Length_Repeat

I had wondered if you could use a field as the "pattern" piece of a Regex expression, and you can! So, using the Lookback of \1, created a formula for a field called "pattern"

Pattern
"("+PadLeft('.',Length([Length_Repeat]),'.')+")\1$"          If we were looking for a pattern of 3 numbers, this would result in (...)\1$

Then, used that in a RegEx_Match([Field1],[Pattern]). Filtered where those were true, added the results.

And then it dawned on me. I was overcomplicating things. No need to generate the number of characters rows. No need for a formula and then a filter. Do it all in a filter and play more with RegEx

For Part 1:

REGEX_Match(tostring([Number]),"(.+)\1$")

Looks for a numeric pattern that repeats once. Because RegEx_Match works on the whole field, you don't need ^ or $

Subtle difference for part 2. Adding the + after \1 means that the pattern might repeat more than once, which allows for 121212

estherb47_0-1764735083632.png

 

Labels
Top Solution Authors