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

16 - Nebula

15 REPLIES 15
12 - Quasar

Wow, that was tough. Cool challenge though! I realized during WC95 that you can graph numbers with the spatial tools, and I appreciated using that to check my work.

Spoiler
To be honest, I'm still not sure why my last fix gave me the right answer. I had to switch my labels in my initial join for "up", "down", "left", and "right".
Here are some logic highlights from my workflow:
- Joining and filtering based on coordinates
- Only including coordinates where the adjacent value is smaller than the current value
- I realized belatedly that every value except 9 should belong to a basin
- Make Group! That tool was my downfall in the Grand Prix, so I feel that I've partially redeemed myself by recognizing and using it successfully here

I've included pictures of my workflow and what the basins graph looked like for my correct answer. I divided all my coordinates by 10 so the earth's curvature didn't distort the graph.

16 - Nebula

This one took longer than expected 😄

Spoiler
15 - Aurora

Today's challenge is tough, too.

Spoiler
Diagonal is not neighborhood, so I sort and sort and...
If there are more complex basins, I will add inner macro...

Macro

Inner Macro

GitHub

8 - Asteroid
Spoiler

Second part is tough, had some tips on using spatial correctly.

15 - Aurora

Wow wow wow. Really had trouble wrapping my head around part 2 of this one. Thank you, @grossal for helping me translate what I wrote down on my graph paper into Alteryx tools!

Spoiler
Part 1, easy peasy. And lessons learned from previous Advent of Codes / weekly challenges. A quick way to get neighbors to points is to use spatial tools.

Just ensure that your lat & lon exist before you try to create a point. I had to divide by 2 (lats are between -90 and 90), and it took me two runs to realize that I was missing 10 rows from my data.

Part 2 was all about making groups. But the first few times I failed to remove all of the instances of 9 as a value on my matrix, so I was only getting 1 group.

I'm not winning tool golf with this, but it's performant and I'm happy with the results.

6 - Meteoroid

This was a good challenge! First time using the make group tool for me. Had fun with it and happy with how clean my solution turned out. Might revisit this and play around with the spatial tools.

8 - Asteroid

@starkey, this is an amazingly clean solution. As much as I like the spatial tools in Alteryx, this is cool.

6 - Meteoroid

thanks!

13 - Pulsar
Spoiler

I spent too long on the first part. I kept getting the wrong answer and couldn't work out what the issue was. Original plan was to use multi-row but added to the fact I wasn't getting the logic as I expected, I didn't like this approach as it wasn't easy to switch between example and input, for example needing to code +/- 10 and 100 respectively.So I ended up building out the logic in a more structured way with joins to find the up, down, left, right positions.

For part 2 it was much quicker building out an iterative macro finding the nearest point for each low point and working outwards from that until you hit the wall of 9's.

Then just because I can't get enough of AoC I thought there would be a spatial solution to this.
So for each point created a trade area (without overlaps) and then removed the points with a depth of 9. This then left me with needing to create combined polygons for these points and I recalled how @jarrod used Make Groups in the Grand Prix in 2020.
I like this approach as you get a nice visual representation of the basins.

It's only after posting that I notice that @clmc9601 did a similar approach using make groups as the first poster of the day! 👏👏👏

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