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
dsmdavid
11 - Bolide
Spoiler
dsmdavid_0-1639088748137.png

Can't say I've often used the make groups tool without the fuzzy match companion, but it was useful today.

SeanAdams
17 - Castor
17 - Castor

Part 1 was super-fun - part 2 is very doable in regular code, but my brain has melted while trying to figure out how to do this in BASEA

 

Part 1 below - part 2 to follow once the brain recovers.

 

Spoiler
The basic process is to give each cell a row & column - and then use multi-row formula to get the neighbours

SeanAdams_0-1639105112047.png


And then transpose this to be able to find the minimum of all neighbours and filter down to these:

SeanAdams_1-1639105195383.png

 

SeanAdams
17 - Castor
17 - Castor

OK - here's part 2.   This one was my favourite so far 'cause once you've prepared the raw materials - the macro part is SUPER clean.

 

Spoiler
Recipe: Again - start by creating a list where each cell knows its neighbours

SeanAdams_0-1639170192941.png

 

Then determine the ones that are low-points and send them into the basin finder:

SeanAdams_1-1639170234028.png

 

The Basin Finder is really simple after you do all this prep.    All you do is you join the current cell to all its neigbours, filter for ones going downhill or 9s - and then repeat

SeanAdams_2-1639170308941.png

 



SeanAdams
17 - Castor
17 - Castor

@starkey   and @clmc9601 I should have used MakeGroup - nicely done!

danilang
19 - Altair
19 - Altair

Another fun non-macro solution.  Spatial to the rescue for part 2

 

Spoiler
danilang_0-1639250821257.png

 

 

Dan

caitlynmcintyre
9 - Comet

This one hurt, but I got there in the end. I thought I was unique in using spatial to figure this out but reading through the thread this was quite common. I probably could have been more efficient but this took me 3 days :'(

 

Spoiler

I created 10,000 polygons and then split out the 9s to make a polygon which i then cut from the larger polygon to give me basins. I then divided the whole area by 10,000 to work out the area per square and divided the basins by this to get the answer

caitlynmcintyre_0-1640042762193.png

 



 

Labels