Member-only story

Advent Of Code 2021 — Hydrothermal Venture — Puzzle 5

Xavier Jouvenot
6 min readJan 31, 2022

--

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

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

Self promotion: You can find other articles on computer science and programming on my website 😉

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:

After playing bingo with a Giant Squid, during the Day 4, we are near the ocean floor and facing a field of hydrothermal vents, which produce big clouds that we should avoid. To help us, the submarine produces a list of the nearby lines of vents:

0,9 -> 5,9
8,0 -> 0,8
9,4 -> 3,4
2,2 -> 2,1
7,0 -> 7,4
6,4 -> 2,0
0,9 -> 2,9
3,4 -> 1,4
0,0 -> 8,8
5,5 -> 8,2

Each line is represented by the coordinate of the start of the line and the coordinate of the end of the line. For now, we are only considering the horizontal lines and the vertical lines, and determine the number of dangerous areas, which are the points where at least 2 lines of vents are traversing.

Solution

--

--

No responses yet