--- Day 9: Smoke Basin ---
or..
Smoke Underwater - A misheard Deep Purple song title.
Part 1
Python
I solved this using look-arounds bounded by input data size. I screwed at least once by using my index as a comparison value instead of as, well, an index... /facepalm. There really wasn't anything special about what I did for this challenge, it just took a while to set up the conditions.
Go
Still catching up
Part 2
Python
What ended up taking me the longest time on this was determining how to maintain my loop exploring a basin size while expanding on the known coordinates on the basin and also not doubling up on coordinates.
My final methodology ended up being:
- Use part 1 to find all of the lows, but store the coordinates as a tuple
- Pass my and each low coordinate into a separate function that:
- added the initial (coord) to a list of coordinates
- initialized an index at 0
- performed the same basic look-around from part 1 but for the coordinate at the index.
- if the value(s) found were not 9, their (coord) was added to coords
- i was incremented and checked against the length of coords
- once i reached the length of coords, it meant we were a) through all of the coords that have been added and b) no longer adding new (coord)
- returned the length of the basin
- Once we had the full list of basins, I sorted it and returned the value of the -1,-2,-3 indexes multiplied together.
Not too terrible, honestly.
Go
We'll see.
<< - Table of Contents - >>