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 3 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

30 REPLIES 30
aiahwieder
9 - Comet

I've tried to do one every day! 🤣 (BTW, @clmc9601, have not got the macro working for Day 2, but maybe I'll send it your way and you can have a look?)

patrick_digan
17 - Castor
17 - Castor
Spoiler
I went for the non-macro solution by employing a lot of copying/pasting :)
image.png
AkimasaKajitani
17 - Castor
17 - Castor

My solution!

 

I read everyone's solution, but there are many ways!

 

My way:

Spoiler
Part 1:

For the first digit, take the largest number from the left. For the second digit, take the largest number from the right. In this case, when taking the first digit, if you take the rightmost character, there will only be one digit, so you need to find the largest number up to the length of the string minus 1. When taking the second digit, take the largest number in the right of the first digit you took.

example :
818181911112111

1st digit taking range : 818181911112111 => The largest number is 9
2nd digit taking range : 818181911112111=> The largest numver is 2
=> 92

Part 2:
First, I thought about the extended part 1 algorythm, but it was failed.
As a result, I went to the brutoforce route.

Part 2 solution :
Removing one digit from each position per row(if there are 100 digits, there will be created 100 patterns.) and keep the pattern that results in the largest number. Repeat this process until you are left with 12 digits.

 

Workflow :

Spoiler
AoC_2025_03_2.png
AoC_2025_03_3.png

Goddenra
8 - Asteroid

The mission to avoid using macros until absolutely have no choice continues 😂

At this rate, the mission won't make it past tomorrow!

Spoiler
Part 1 was straightforward with a bit of Regex and Generate Rows.

Part 2 does lend itself to an iterative macro, but took cut and paste approach. If using this in anger then would tidy up the pelican beak with one.
Screenshot 2025-12-03 145111.png

lwolfie
11 - Bolide

Forced myself to do an iterative macro.  Thank you AoC for strengthening my skills!

mmontgomery
11 - Bolide
11 - Bolide

Day 3

Spoiler
P1 was rather straight forward. Just find the max value of all values that arent last, then find the next largest number
P2 took some time to think about approach. What I did was determine the values remaining and find the position to the left of that, find the max value then add it to a series. From there, find that last value position, and find the range of values that are before the end that are in scope to check (allowing the remaining numbers).


IOW:

987654321111111
This has 15 values, so I check position 1, 2, 3, 4, as each of those could allow the remaining values after. I find the max of 1,2,3,4, which is position 1: 9.

Once I pick position 1, then I do the same process: 2,3,4,5 for second value and so on and add it to my series
2025_Day3_Macro.jpg2025_Day3.jpg

 

JeffF
Alteryx
Alteryx
Spoiler
I stuck to the copy and paste approach, since I was tired and there weren't very many digits. I'll probably create a macro later for fun.
Day03-JeffF.png
OllieClarke
16 - Nebula
16 - Nebula

Initially tried a macro, but it would have blown up my computer, so after a chat with @robbinrv I thought of another approach. The real nice thing about this is it works for both parts (or any number of batteries) based on a single config

Spoiler
Day 3.pngDay 3 calcs1.png
I spent most of my time debugging this calc, trying to do it in one (without the need for the searchspace calc), but in the end I landed on this:
Day 3 calcs2.png
Erin
11 - Bolide

I must admit, I peeked at some of the posted solutions because I got a little stuck. And then I quickly realized that my brain does not work like the geniuses that posted before me....Oh well. Somehow rather I made it through!

I did use an Iterative macro for part two because I'm basic. And also I'm not playing tool golf. 

 

Spoiler
Day3.png


Part Two Macro - 
Day3 Iterative Macro.png
ScottLewis
11 - Bolide

Similar Macro solution to others.

I default to Iterative Macros for AOC solutions because they map to how I think about problems, so no surprise that was my route here.

 

I will note that CoG's solution below is absolutely glorious. I'm so keyed on the AOC problems that lock up your computer when you try to solve them directly that I didn't even consider the idea of data expansion to allow for a dynamic programing solution. Solutions like this tend to run in N^2 or worse time, so be careful with them when things get larger, but revel in the mathy goodness until then.

 

In lieu of a proper writeup, here are some things that I had to debug out of my macro for anyone struggling:

 

 

Spoiler

Data type. I'm just old enough to have been taught to use minimal data types to optimize storage. That is no longer a reasonable paradigm. Just use INT64 for everything and make sure your macro isn't converting. I just throw a select at the beginning to force the data types.

 

Adjusting how many batteries to check. I initially missed that after checking N batteries if I selected anything except the first, you have to reduce N by the Position-1 of your selection. Think of this as spending your budget of ignored batteries. Sum->CountNULL helped here.

 

Join->Union pattern for preserving data grain. To implement the adjustment to the number of batteries to check each iteration, I was joining the CountNull back with the original data set. Problem here is that after some number of iterations there were no NULLs, so the join output wasn't sufficient, I also needed the unjoined Left. So join, union back, turn off the field warning on the join. Patterns.

A side note there that it helps to be consistent with Join inputs. I build joins such that the Left is always the data set and the Right is the new thing being added. That way I can think of preserving record count on Left+Join as a basic test of join logic. 

 

 

 

Labels
Top Solution Authors