adventOfCode/challenges/2021/09-smokeBasin
2021-12-09 21:26:08 +00:00
..
py Add 2021-09 in Python (with visualisation) 2021-12-09 21:26:08 +00:00
benchmark.json Add 2021-09 in Python (with visualisation) 2021-12-09 21:26:08 +00:00
info.json Add 2021-09 in Python (with visualisation) 2021-12-09 21:26:08 +00:00
partTwo.mp4 Add 2021-09 in Python (with visualisation) 2021-12-09 21:26:08 +00:00
README.md Add 2021-09 in Python (with visualisation) 2021-12-09 21:26:08 +00:00

Day 9: Smoke Basin

The key to solving part two is knowing that you don't need to itelligently think about the depths of the basins.

Because we know that

Locations of height 9 do not count as being in any basin, and all other locations will always be part of exactly one basin

we can determine that a given basin is bounded by 9s or the edge of the board. For example, the sample input looks like this if you remove all digits apart from 9.

--999-----
-9---9-9--
9-----9-9-
-----9---9
9-999-----

We can find every lowest point, and work outwards from that point to find the entire basin.


Part two visualisation

To run the visualisation, use the following command:

PYTHONPATH=<path to repo root>/lib python3 -B -c "import py;inp=open('input.txt').read();py.Challenge.vis(inp,'visdir')"