aoc-2021-rust

Advent of Code 2021 Solutions in Rust
git clone https://git.sinitax.com/sinitax/aoc-2021-rust
Log | Files | Refs | README | sfeed.txt

part1 (1745B)


      1--- Day 9: Smoke Basin ---
      2
      3These caves seem to be lava tubes. Parts are even still volcanically active; small hydrothermal
      4vents release smoke into the caves that slowly settles like rain.
      5
      6If you can model how the smoke flows through the caves, you might be able to avoid it and be that
      7much safer. The submarine generates a heightmap of the floor of the nearby caves for you (your
      8puzzle input).
      9
     10Smoke flows to the lowest point of the area it's in. For example, consider the following heightmap:
     11
     122199943210
     133987894921
     149856789892
     158767896789
     169899965678
     17
     18Each number corresponds to the height of a particular location, where 9 is the highest and 0 is the
     19lowest a location can be.
     20
     21Your first goal is to find the low points - the locations that are lower than any of its adjacent
     22locations. Most locations have four adjacent locations (up, down, left, and right); locations on the
     23edge or corner of the map have three or two adjacent locations, respectively. (Diagonal locations do
     24not count as adjacent.)
     25
     26In the above example, there are four low points, all highlighted: two are in the first row (a 1 and
     27a 0), one is in the third row (a 5), and one is in the bottom row (also a 5). All other locations on
     28the heightmap have some lower adjacent location, and so are not low points.
     29
     30The risk level of a low point is 1 plus its height. In the above example, the risk levels of the low
     31points are 2, 1, 6, and 6. The sum of the risk levels of all low points in the heightmap is
     32therefore 15.
     33
     34Find all of the low points on your heightmap. What is the sum of the risk levels of all low points
     35on your heightmap?
     36
     37