Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

General Discussions

Discuss any topics that are not product-specific here.

Advent of Code 2021 Day 9 (BaseA Style)

jdunkerley79
ACE Emeritus
ACE Emeritus

Discussion thread for day 9 of the Advent of Code - https://adventofcode.com/2021/day/9

 

JessL_0-1639060465861.jpeg

 

15 REPLIES 15
clmc9601
13 - Pulsar
13 - Pulsar

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.

Screen Shot 2021-12-09 at 12.07.30 AM.pngScreen Shot 2021-12-09 at 12.15.01 AM.png
afv2688
16 - Nebula
16 - Nebula

This one took longer than expected 😄

 

Spoiler
Untitled.png
AkimasaKajitani
17 - Castor
17 - Castor

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...

AkimasaKajitani_0-1639065245244.png

Macro

AkimasaKajitani_1-1639065266803.png

Inner Macro
AkimasaKajitani_2-1639065284312.png

 

 

GitHub

https://github.com/AkimasaKajitani/AdventOfCode/tree/main/2021

 

LiuZhang
9 - Comet
Spoiler
9.png

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

estherb47
15 - Aurora
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.

estherb47_0-1639068480416.png

 




 

 

starkey
7 - Meteor

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.

starkey_2-1639070701538.png

 

 

 

 

 

DataG8
8 - Asteroid

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

starkey
7 - Meteor

thanks!

cgoodman3
14 - Magnetar
14 - Magnetar
Spoiler
cgoodman3_0-1639084604894.png

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.

cgoodman3_1-1639084947815.png

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.

cgoodman3_2-1639085167411.png

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
Labels