Member-only story

Advent Of Code 2021 — Smoke Basin — Puzzle 9

Xavier Jouvenot
7 min readFeb 28, 2022

--

Hello ! I’m Xavier Jouvenot and here is the 9th part of a long series on Advent Of Code 2021.

For this new post, we are going to solve the problem from the 9th December 2021, named “Smoke Basin”. The solution I will propose in C++, but the reasoning can be applied to other languages.

Self promotion: Here are a few social networks where you can follow me and check my work as a programmer and a writer 😉 personal website, Twitter, Dev.to, CodeNewbie, Medium, GitHub

Part 1

The Problem

The full version of this problem can be found directly on the Advent of Code website, I will only describe the essence of the problem here:

Today, we realize that the cave in which we are navigating are lava tubes, some of them being still active and smoke flowing through most of them. To avoid any dangerous situation, we study the height map generated by the submarine which looks like:

2199943210
3987894921
9856789892
8767896789
9899965678

Our first goal is to find the lowest points on this map. A lowest point is a point where all the adjacent location are higher (not counting diagonals). Then, to calculate the risk level of each of them (which has a value of 1 plus the height of the low point) and summing them all.

Solution

First of all, to be able to focus on the problem at hand, I have directly made the input…

--

--

No responses yet