Day 9
[advent-of-code-2021.git] / day09 / task.txt
1 --- Day 9: Smoke Basin ---
2 These caves seem to be lava tubes. Parts are even still volcanically active; small hydrothermal vents release smoke into the caves that slowly settles like rain.
3
4 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).
5
6 Smoke flows to the lowest point of the area it's in. For example, consider the following heightmap:
7
8 2199943210
9 3987894921
10 9856789892
11 8767896789
12 9899965678
13 Each number corresponds to the height of a particular location, where 9 is the highest and 0 is the lowest a location can be.
14
15 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.)
16
17 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.
18
19 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.
20
21 Find all of the low points on your heightmap. What is the sum of the risk levels of all low points on your heightmap?
22
23 Your puzzle answer was 541.
24
25 --- Part Two ---
26 Next, you need to find the largest basins so you know what areas are most important to avoid.
27
28 A basin is all locations that eventually flow downward to a single low point. Therefore, every low point has a basin, although some basins are very small. Locations of height 9 do not count as being in any basin, and all other locations will always be part of exactly one basin.
29
30 The size of a basin is the number of locations within the basin, including the low point. The example above has four basins.
31
32 The top-left basin, size 3:
33
34 2199943210
35 3987894921
36 9856789892
37 8767896789
38 9899965678
39 The top-right basin, size 9:
40
41 2199943210
42 3987894921
43 9856789892
44 8767896789
45 9899965678
46 The middle basin, size 14:
47
48 2199943210
49 3987894921
50 9856789892
51 8767896789
52 9899965678
53 The bottom-right basin, size 9:
54
55 2199943210
56 3987894921
57 9856789892
58 8767896789
59 9899965678
60 Find the three largest basins and multiply their sizes together. In the above example, this is 9 * 14 * 9 = 1134.
61
62 What do you get if you multiply together the sizes of the three largest basins?
63
64 Your puzzle answer was 847504.
65
66 Both parts of this puzzle are complete! They provide two gold stars: **
67
68 At this point, you should return to your Advent calendar and try another puzzle.
69
70 If you still want to see it, you can get your puzzle input.
71
72 You can also [Share] this puzzle.