alteryx Community

General Discussions

Discuss a wide range of topics! Questions about the Alteryx Platform should be directed to the appropriate Product discussion forum.

Advent of Code 2021 Day 13 (BaseA Style)  16 - Nebula 9 REPLIES 9 12 - Quasar

Nice to have a shorter challenge this time!

Spoiler
I calculated what the new (flipped) values should be for any coordinates affected by the fold and then used an iterative macro to incrementally apply each fold's logic.   7 - Meteor

Took me 30 min to figure out in one of my convoluted formulas I put an X where I needed a Y. Fun solution without an iterative macro.

Spoiler   13 - Pulsar
Spoiler
It's so nice to go back to quicker challenges to solve, but oh my! I really struggled with getting my x folds the wrong way around, I kept looking at the output thinking none of these look like letters. It was fine for the input with only one fold where the direction didn't matter.

I copy and pasted the instructions and the dot positions into two inputs, and used the selector macro to choose which input to use. Originally I just did it by brute force for speed as it was only 12 instructions to replicate, however due to my folding error I ended up building a macro to check my answers Using the spatial tools to plot points gets you a nice and easy to read output. Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com  13 - Pulsar

@bflick nice non-macro solve 👍

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com  16 - Nebula

Wanted to be the first non macro 😅 oh well, here it is anyway

Spoiler  15 - Aurora

Today is iterative day.

Spoiler
I made all fold it up at star 1. But it should be made for star2. Macro GitHub  15 - Aurora

Bizarrely enough, my macro approach failed, so here is a non-macro version.

Spoiler
Thinking through the process, you can take a single point, and apply all transformations needed to each point, then move to the next one. So, for the example, there are two transformations. Bring the first point 6,10 through the y change and the x change, and you get 4,4 (change both x and y)

First, generate the number of transformations with a record ID and then the Max record ID, and then use a generate rows tool to generate those amount of transformations for each point.

My multirow formula is admittedly ugly. I didn't want to do separate ones for x and y

Spoiler

IF [Step]=1 THEN
IF [Axis]="x" AND [Shift]<tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$1"))
THEN tostring(tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$1"))-2*(tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$1"))-[Shift]))+","+REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$2")
ELSEIF [Axis]="y" AND [Shift]<tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$2"))
THEN REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$1")+","+tostring(tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$2"))-2*(tonumber(REGEX_Replace([Point], "(\d+)\D+?(\d+)", "\$2"))-[Shift]))
ELSE [Point] ENDIF

ELSEIF [Axis]="x" AND [Shift]<tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$1"))
THEN tostring(tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$1"))-2*(tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$1"))-[Shift]))+","+REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$2")
ELSEIF [Axis]="y" AND [Shift]<tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$2"))
THEN REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$1")+","+tostring(tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$2"))-2*(tonumber(REGEX_Replace([Row-1:New], "(\d+)\D+?(\d+)", "\$2"))-[Shift]))
ELSE [Row-1:New]
ENDIF

Laying everything out from the last transformation with spatial tools made it easier to read the letters (after I remembered to make the "y" values negative so as not to have upside down letters    17 - Castor

Very similar situation to @clmc9601  @cgoodman3 - but I used the reporting tools to generate the output instead.

Also - mine had custom picked icons for the macros - it's those extra little touches that count (or so I hear).

Spoiler
Recipe:
First prep all the data, moving the folds and the dots into 2 different data sets
Then iterate through the folds in an iterative macro - and keep the new paper in a second set of data that you iterate through.
All you need to do is to adjust the X or Y value of each dot based on the fold, and use a unique to get rid of duplicates And here's the macro that does the folding:  8 - Asteroid

Is it cheating if i rendered the answer using excel because reporting tools are too difficult?

edit: as a self-proclaimed spatial tool fan i'm ashamed i didn't think of create points... i've done too many challenges today

Spoiler  