AoC 2021 D9: Smoke Basin
| Problem statement | Source code | Tags: BFS/DFS
← Previous Back to AoC Index Next →
Part 1
The low points are those that are lower than all of their adjacent points (up, down, left, right). Just iterate through all points and check their neighbors.
Part 2
A canonical flood fill problem. I use DFS here. For each low point, I start a DFS that visits all neighbors with height less than 9. The size of the basin is the number of points visited in this DFS.