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 5 (BaseA Style)

16 - Nebula

18 REPLIES 18
13 - Pulsar

@grossal 👏 going the extra step to use a count records instead of being lazy and using browse anywhere to get the total records.

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
18 - Pollux

Lulling us into a false sense of security with a relatively easy one on Day 5!

And I've forgotten even if I went to high school, let alone any math I may have done there!

Spoiler
The delta on the diagonals is always +/- 1 along both axes.  Once you generate the points along one axis, you can use a multi-row(one of my favorite tools) to number the points and use the point number to calculate the offset from the start along the other.

Edit: I guess I did go to high school and something stuck since I used the word "delta" in the spoiler

Dan

14 - Magnetar

I have to pass today, I couldn't understand the problem.

16 - Nebula

Nice one for today 🙂

Spoiler
8 - Asteroid
Spoiler

Realise using straight line formula will probably made it easier. Since direction doesn't seem to matter, sort from low value to higher value may simplify things as well.

11 - Bolide

Have you ever found yourself making a macro for 15-20 minutes on auto-pilot before you realize you don't need a macro? Huh? Oh yeah, me neither...

Ugh, I struggled a bit initially with part 2 until my wife (who teaches math/science) was gracious enough to re-teach me y=mx+b (which she was quite excited to see make an appearance "out in the wild", let me tell you). After thinking about it through this lens, it was frustratingly simple.

Spoiler

17 - Castor

My solution is very similar to @afv2688 and @patrick_digan

(oh, and I'm using a few of the shared macros that folk have posted like the downloader and the switcher - thank you!)

Spoiler

- First split out the data into unique X&Y values using a regex
- Then split this into rows which are horizontal (constant Y) vs. any other line
- For the horizontal lines - iterate over Y since X does not vary - for example, the line Y=3
- For all other lines - iterate over X using the formula Y =  mX + C.    m is found using the (Y2-Y1)/(X2-X1) gradient function; and then c can be found by substituting any known X,Y combination into the formula above once m is known

- Once you've created all the points - you then just need to count how many times any given point occurs - so Part 1 is identical to part 2, but part 1 just excludes diagonals.

8 - Asteroid

From now on I'm building something that works with the example data, then plugging in my data. Saves so much time.

Spoiler

I'm sure there's a more mathematically sound way to do this but it works!

8 - Asteroid

I guess I took more of a brute-force approach; similar to other solutions, but didn't use y=mx+b (been WAY too long since school).

Oh, well - got the right answers...

Mark