Discussion thread for day 4 of the Advent of Code - https://adventofcode.com/2024/day/4
Most fun and head scratching one yet!
Never expected a use case like this in Alteryx. Tricky one to solve the word search diagonally. Had to take a hint for that bit.
Actually really enjoyed this one, I wasted a whole hour trouble shooting unnecessarily, I think my second answer to part 2 was mistyped into the website the first time I got it... As after a thorough troubleshoot I still couldn't find anything wrong with my solution, tried the same value I was getting consistently and voila....
Always fun to see what your actual input/solutions look like with these ones! (after the stars have been secured of course...)
Went with generating the row/col of each target letter, for each direction, for each possible starting letter to find the XMASs, then for each A as midpoint, what are the 4 corners, are they M or S, and then finally, are my matches conforming to the MAS diagonals logic.
Change the extension of my xml file to .twb to take a gander at the tableau output. Not insightful, but cool to see.
Well this one kicked my butt 😥 but I learned a lot! I was good up until the diagonal matches. I remember a puzzle with diagonal patterns from last year's AoC and I never got through it. Thankfully, everyone here is way smarter than me and posted solutions that were easy to follow so I could learn some new tricks with diagonal patterns 😉.
And a huge thank you to @CoG for having a solution that was so easy to follow that I was able to essentially repeat it (and understand why it worked) and live to see another day of AoC!
In a true act of self-hatred, I saw a couple of people mention RegEx in the WhatsApp discussion group and it made me think... surely this could be done in a single Formula expression? A bit of trial and error later and I present to you one of the most disgusting things created by mankind. 1473 & 765 characters respectively.
REGEX_CountMatches([DownloadData], '(?=XMAS|SAMX)')
+
REGEX_CountMatches([DownloadData], '(?=X.{'+ToString(FindString([DownloadData], '
'))+'}M.{'+ToString(FindString([DownloadData], '
'))+'}A.{'+ToString(FindString([DownloadData], '
'))+'}S)')
+
REGEX_CountMatches([DownloadData], '(?=S.{'+ToString(FindString([DownloadData], '
'))+'}A.{'+ToString(FindString([DownloadData], '
'))+'}M.{'+ToString(FindString([DownloadData], '
'))+'}X)')
+
REGEX_CountMatches([DownloadData], '(?=X.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}S)')
+
REGEX_CountMatches([DownloadData], '(?=S.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))+1)+'}X)')
+
REGEX_CountMatches([DownloadData], '(?=X.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}S)')
+
REGEX_CountMatches([DownloadData], '(?=S.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}X)')
REGEX_CountMatches([DownloadData], '(?=M.M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}S.S)')
+
REGEX_CountMatches([DownloadData], '(?=M.S.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}M.S)')
+
REGEX_CountMatches([DownloadData], '(?=S.M.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}S.M)')
+
REGEX_CountMatches([DownloadData], '(?=S.S.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}A.{'+ToString(ToNumber(ToString(FindString([DownloadData], '
')))-1)+'}M.M)')
@DataNath
You are amazing..👍