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

28 REPLIES 28
gawa
16 - Nebula
16 - Nebula

The 1st day we need Iterative Macro, I think.

Spoiler
image.png
Part1
Simply create all combination of 2 digits, and found maximum value.

Part2
We need to examine 12 digits, that brute force approach will be failed.
1) Let character positions 1, 2, 3,,,,from left as ID.
2) Starting from all IDs, append single character that has higher ID in each iteration, and memorize appended ID as current ID.
3) Before moving to next iteration, find maximum value within the same current ID, and pass them to next iteration
 *Value lower than maximum value at this point will have no chance to be maximum after all iteration.
Hub119
12 - Quasar
12 - Quasar

@gawa Day 3 going iterative does seem early... but who knows what will happen with a 12 day AoC this year?

Spoiler
WorkflowWorkflow
Spoiler
The trick here was to use the iteration number to grab all battery positions that allowed for enough remaining batteries (to the right) to still be present and then determine the maximum "joltage" available each iteration through the macro.
P2 MacroP2 Macro
PangHC
13 - Pulsar

throw all to multiple-row tool. 800+ chars. 

glad i know excel to help.

Spoiler
take first 12 char then just replace every char and get the max.
spam multi-row tool to avoid macro 🤣

PangHC_0-1764744080059.png

formula if you interest

if length([row-1:max])<12 then
  [row-1:max]+[data]
else
  max(tonumber([row-1:max]), 
tonumber(Substring([row-1:Max],1,12)+[data]),
tonumber(left([row-1:Max],1)+Substring([row-1:Max],2,12)+[data]),
tonumber(left([row-1:Max],2)+Substring([row-1:Max],3,12)+[data]),
tonumber(left([row-1:Max],3)+Substring([row-1:Max],4,12)+[data]),
tonumber(left([row-1:Max],4)+Substring([row-1:Max],5,12)+[data]),
tonumber(left([row-1:Max],5)+Substring([row-1:Max],6,12)+[data]),
tonumber(left([row-1:Max],6)+Substring([row-1:Max],7,12)+[data]),
tonumber(left([row-1:Max],7)+Substring([row-1:Max],8,12)+[data]),
tonumber(left([row-1:Max],8)+Substring([row-1:Max],9,12)+[data]),
tonumber(left([row-1:Max],9)+Substring([row-1:Max],10,12)+[data]),
tonumber(left([row-1:Max],10)+Substring([row-1:Max],11,12)+[data]),
tonumber(left([row-1:Max],11)+Substring([row-1:Max],12,12)+[data]))
endif
 

Qiu
21 - Polaris
21 - Polaris

I used an iterative macro.

Spoiler
AoC 2025 Day 03.png
CoG
14 - Magnetar

Dynamic Non-Macro Solution! Since I started quite late and had a strong feeling this was possible without a macro, I took my time and built this solution.

 

Spoiler
Screenshot.png
This is a Dynamic Programming (DP) problem (computer science designation for problems that can be solved more efficiently by solving and saving the results of more and more complex sub-problems). The tricky part for problems like this is in identifying the sub problem, although solving Base-A adds an additional challenge, which is why macros are so appealing here!

Simplified version of the sub-problem: what is the maximum digit in the last k characters of the joltage rating? 
Notice that the first case (k=1) is, trivially, just the last digit, and each successive k can be determined by maximum of the k-th right-most digit and the result of DP(k-1). which is a perfect use case for the Multi-Row Formula Tool.

There is a complicating factor, which is that the first digit of our Joltage output cannot be the last digit of the Joltage Rating (our main string input). The fix for this is handled by the Generate Rows Tool above, where we perform this maximum digit procedure for each character of our output, zeroing out the relevant right-most digits.

Once we have all of this data, constructing the actual Joltage output is not too difficult as we can perform a greedy algorithm, to select the first occurrence of the next largest digit for each character in our output. 

Happy Solving!

 

danboll_life
9 - Comet

Initially, my solution generated way too many records.

Spoiler
danboll_life_0-1764751593382.png

 

DaisukeTsuchiya
14 - Magnetar
14 - Magnetar

I was initially unsure how to structure the logic for P2. However, once I understood it, the workflow proved to be less complex than I first thought.

Spoiler

- P1
The general idea was to select the largest digit from the right side of each position to create a two-digit number, and then select the largest among those.

- P2

The specific logic for P2 is as follows:

  • To determine the 1st digit (from the left):

    1. Create a search range by taking the original number and excluding the last 11 digits. Find the largest digit within this range. If there are duplicates of the largest digit, select the one that appears first (the leftmost one).
    2. The selected digit and all digits to its left are now considered "used" and will be excluded from the next steps.
  • To determine the 2nd digit:

    1. From the remaining unused digits, create a new search range by excluding the last 10 digits. Find the largest digit within this new range, again selecting the leftmost one in case of a tie.
    2. The newly selected digit and all digits to its left (within the current remaining set) are now considered "used."
  • To determine the 3rd digit:

    1. From the remaining unused digits, create a new search range by excluding the last 9 digits. Find the largest digit within this new range, selecting the leftmost one in case of a tie.
    2. The newly selected digit and all digits to its left are now considered "used."

This process is repeated in the same manner for the subsequent digits.

Finally, the 12 extracted digits are concatenated to form the resulting number, which completes the process.

スクリーンショット 2025-12-03 194519.jpg
<P1 Batch Macro>
スクリーンショット 2025-12-03 194546.jpg
<P2 Itterative Macro>
スクリーンショット 2025-12-03 194604.jpg

 

DanFlint
8 - Asteroid
Spoiler
DanFlint_0-1764761024848.png

Started off part 1 by building an array. This would probably brute force part 2, but was taking too much time and laptop to finish.

Refactored into a more optimised solution that I could build into an iterative macro for part 2.

DataNath
17 - Castor
17 - Castor

Day 3 done! I knew as soon as I started Part 1 that there'd be a Part 2 along those lines... but that didn't stop me getting a quick star before reevaluating my life decisions. Went down the macro route like most others for P2 - took a little while to figure out the logic and troubleshoot my filtering but got there in the end! A fun challenge!

 

Spoiler
Workflow.png

Iterator.png

 

Labels
Top Solution Authors