Advent of Code 2024 Day 4 (BaseA Style)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 4 of the Advent of Code - https://adventofcode.com/2024/day/4
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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. 🌟🌟🎅
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Question 2 was toooooooo difficult
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
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)
By doing so, the number of records at last iteration will be the answer of part1.
Result looks like this
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.
Result looks like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
 
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
