We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 3 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

78 REPLIES 78
Sebastian_Chaieb2
11 - Bolide
11 - Bolide

Not perfect but works :P

Spoiler
Day3.png

Tokimatsu
12 - Quasar

This is good for regex.

Spoiler
スクリーンショット 2024-12-03 144834.png

 

 

niklas_greilinger
11 - Bolide

Quite complicated approach but at least I got there :D

Spoiler
WF.pngMacro.png
rbgruwel
8 - Asteroid

Nice start of the day wih a Regex Expression

Spoiler
Example.png
Samantha_Jayne
Alteryx
Alteryx

I loved using my Regex skills. I have not yet attempted tool golf, but I can see how it can be done. The spoiler includes both stars!

 

Spoiler
Day 3 - Both Stars.png

 

 

Samantha Clifton
Alteryx
#alteryxrocks
DataNath
17 - Castor
17 - Castor

Day 3 in the bag! Lovely little treat after yesterday's cheeky part 2.

 

Spoiler
Day 3.png
Spainey
9 - Comet

Very nice Regex challenge today :)

Spoiler
I used Regex to Tokenize the text to Rows:
do\(\)|don't\(\)|mul\(\d+,\d+\)​

Then I used a Formula tool to parse out the numbers and multiply them - again Regex. I used Regex_Replace and created capture groups with round brackets - then I replaced the text by referencing the capture group by number ($1/$2):
Number 1:
IF StartsWith([data], "mul")
THEN ToNumber(REGEX_Replace([data], "mul\((\d+),(\d+)\)", "$1"))
ELSE 0
ENDIF

Number 2:
IF StartsWith([data], "mul")
THEN ToNumber(REGEX_Replace([data], "mul\((\d+),(\d+)\)", "$2"))
ELSE 0
ENDIF​

For Part 2, I just needed to flag an On/Off status using the do()/don't() records, which I used a Multi-Row Formula for:
IF [RecordID] = 1 
THEN "On"
ELSEIF [data] = "don't()"
THEN "Off"
ELSEIF [data] = "do()"
THEN "On"
ELSE [Row-1:Status]
ENDIF

After just keeping the "On" records the data can be aggregated like it was with Part 1.

AoC 2024 Day 3.png

 

Bobbyt23
13 - Pulsar

Regex fun, felt a lot less painful than yesterday but feel I may be being lulled in to a false sense of security.

Spoiler
image.png
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

My solution.

I usually set "group by [RecordID]" for all cases in Multi-Row Formula, but this time it was a pitfall...

 

Spoiler
Workflow
workflow.png
Part 1
Regex Tool
Tokenize
(mul\(\d+,\d+\))

Formula Tool
x = ToNumber(REGEX_Replace([Field_1], "mul\((\d+),.*", "$1"))
y = ToNumber(REGEX_Replace([Field_1], ".*,(\d+)\)", "$1"))
mul = x * y

Part 2
RegEx Tool
Tokenize
do\(\)|don't\(\)|mul\(\d+,\d+\)

Multi-Row Formula
active = 
IF IsEmpty([Row-1:active]) THEN "True"

ELSEIF [Field_1] = "don't()" THEN "False"
ELSEIF [Field_1] = "do()" THEN "True"
ELSE [Row-1:active]
ENDIF

Formula Tool 
(same as Part 1)

 

OllieClarke
15 - Aurora
15 - Aurora

I'm sure there's a 3 tool solution out there...
edit: of course @gawa has it!

Spoiler
image.png


 

Labels
Top Solution Authors