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 122[1m[37m1[0m9994321[1m[37m0[0m 133987894921 1498[1m[37m5[0m6789892 158767896789 16989996[1m[37m5[0m678 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 [1m[37mlow points[0m - 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 [1m[37mfour[0m 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 [1m[37mrisk level[0m of a low point is [1m[37m1 plus its height[0m. 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 [1m[37m15[0m. 33 34Find all of the low points on your heightmap. [1m[37mWhat is the sum of the risk levels of all low points 35on your heightmap?[0m 36 37