day 5, parts 1 & 2 (C)

This commit is contained in:
2021-12-05 13:43:58 +01:00
parent 736cae886a
commit 0ea7a9278a
4 changed files with 270 additions and 9 deletions

View File

@@ -41,4 +41,34 @@ To avoid the most dangerous areas, you need to determine the number of points wh
Consider only horizontal and vertical lines. At how many points do at least two lines overlap?
To begin, get your puzzle input.
Your puzzle answer was 4655.
--- Part Two ---
Unfortunately, considering only horizontal and vertical lines doesn't give you the full picture; you need to also consider diagonal lines.
Because of the limits of the hydrothermal vent mapping system, the lines in your list will only ever be horizontal, vertical, or a diagonal line at exactly 45 degrees. In other words:
An entry like 1,1 -> 3,3 covers points 1,1, 2,2, and 3,3.
An entry like 9,7 -> 7,9 covers points 9,7, 8,8, and 7,9.
Considering all lines from the above example would now produce the following diagram:
1.1....11.
.111...2..
..2.1.111.
...1.2.2..
.112313211
...1.2....
..1...1...
.1.....1..
1.......1.
222111....
You still need to determine the number of points where at least two lines overlap. In the above example, this is still anywhere in the diagram with a 2 or larger - now a total of 12 points.
Consider all of the lines. At how many points do at least two lines overlap?
Your puzzle answer was 20500.
Both parts of this puzzle are complete! They provide two gold stars: **