Free Trial

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2024 Day 4 (BaseA Style)

AlteryxCommunityTeam
Alteryx Community Team
Alteryx Community Team

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

60 REPLIES 60
clmc9601
13 - Pulsar
13 - Pulsar

Wow, my solution is way over-engineered compared to the simpler ones. Looking forward to reviewing the elegant ones another day!

DaisukeTsuchiya
14 - Magnetar

I wanted to make it simpler, but it became complicated. 😣

Spoiler
スクリーンショット 2024-12-04 164424.png




 

 

LHolmes
9 - Comet

Way overthought part 2; going down the rabbit hole of matrix manipulation...when I finally realized a few formulas would work nicely.

Could be more elegant, but I'm happy with my stars. 🌟🌟🎅

Spoiler
2024 Day 4 Part 12024 Day 4 Part 1
2024 Day 4 Part 22024 Day 4 Part 2
danboll_life
8 - Asteroid

Question 2 was toooooooo difficult

Spoiler
AoC_2024_04.png

niklas_greilinger
9 - Comet

Restarted like 5 times with different approaches cause I could not figure out how to build the matrix but found a neat way in the community!

Spoiler
WF.png
Qiu
21 - Polaris
21 - Polaris

Brutal Force again but it costs me only 0.6 seconds to run for P1 and P2.

AOC2024-Day04.png

 

gawa
16 - Nebula
16 - Nebula

At first I made messy and ugly WF but now I refined it with 'Spatial Analysis' version as fun analysis.

When it comes to X-Y coordinates, I cannot stop using spatial analysis.

Spoiler
First, create Iterative Macro to trace the path for the given search words that is 'XMAS' for part1 and 'MAS' for part2. I used Text Box interface to accept variable search word.
Within this macro, it searches words X=>M=>A=>S in turn for each iteration. Logic to find next word is;
(1) Find the nearest points that has next target character by combo of Trade Area + Spatial Match tools.
(2) Find the direction of next character, and only when it matches the existing direction, it passes to next iteration
Pass
East=>East=>East...
NW=>NW=>NW....
*these are linear lines
Not pass
East=>East=>West
NW=>SW
*these are zigzag(non-linear)
image.png
By doing so, the number of records at last iteration will be the answer of part1.
Result looks like this
image.png

As for part2, by using the same Macro, find all spatial object of tracing "MAS" at first. Then, filter the records with direction of "NW", "NE", "SW", or "SE" to find the diagonal lines.
In order to judge which objects are crossing as "X", convert line objects to rectangular , and Spatial Match as "Where target Contains universe". Result will include duplicated result (matching result of "target object=1 and universe object=2", "target object=2 and universe object=1" are identical), so remove duplication by Filter tool, and count the number of record in true anchor.
image.png
Result looks like this
image.png

mark-spain
8 - Asteroid

That was tough! Horizontal and Vertical were pretty nice, but I had to really think about how to transform the data for those diagonals. 

I learnt a new function today too: Regex_CountMatches(), which counts the occurrence of a pattern inside a string. By transforming the data for each of the directions and concatenating new strings, I could use the function to get accurate counts :)

Spoiler
AoC 2024 Day 4.png

 

JasperMB
8 - Asteroid
Spoiler
AoC_4.png

 

cgoodman3
14 - Magnetar
14 - Magnetar
Spoiler
A familiar type of challenge as other years splitting out the grid into a flat structure of column (x), row (y), value.

Got caught out with direction as moving up is actually -1 on row count! And for part two originally finding '+' as well as 'x' patterns, only for it to say my result was too high.  Which initially resulted in rebuilding my part 2 logic only to then get the same answer before removing the '+' matches.

Screenshot 2024-12-04 113650.png


Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Labels
Top Solution Authors