You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB
Markdown

3 years ago
https://adventofcode.com/2021/day/9
## \--- Day 9: Smoke Basin ---
These caves seem to be [lava tubes](https://en.wikipedia.org/wiki/Lava_tube).
Parts are even still volcanically active; small hydrothermal vents release
smoke into the caves that slowly settles like rain.
If you can model how the smoke flows through the caves, you might be able to
avoid it and be that much safer. The submarine generates a heightmap of the
floor of the nearby caves for you (your puzzle input).
Smoke flows to the lowest point of the area it's in. For example, consider the
following heightmap:
[code]
2 _1_ 9994321 _0_
3987894921
98 _5_ 6789892
8767896789
989996 _5_ 678
[/code]
Each number corresponds to the height of a particular location, where `9` is
the highest and `0` is the lowest a location can be.
Your first goal is to find the _low points_ \- the locations that are lower
than any of its adjacent locations. Most locations have four adjacent
locations (up, down, left, and right); locations on the edge or corner of the
map have three or two adjacent locations, respectively. (Diagonal locations do
not count as adjacent.)
In the above example, there are _four_ low points, all highlighted: two are in
the first row (a `1` and a `0`), one is in the third row (a `5`), and one is
in the bottom row (also a `5`). All other locations on the heightmap have some
lower adjacent location, and so are not low points.
The _risk level_ of a low point is _1 plus its height_. In the above example,
the risk levels of the low points are `2`, `1`, `6`, and `6`. The sum of the
risk levels of all low points in the heightmap is therefore `_15_`.
Find all of the low points on your heightmap. _What is the sum of the risk
levels of all low points on your heightmap?_