Include my answers in the problem

This commit is contained in:
2019-12-04 08:45:25 -06:00
parent 6068855fa1
commit d11064755a
3 changed files with 219 additions and 64 deletions

View File

@@ -2,17 +2,20 @@ Advent of Code
--- Day 3: Crossed Wires ---
The gravity assist was successful, and you're well on your way to the Venus refuelling station. During the rush back on Earth, the fuel management
system wasn't completely installed, so that's next on the priority list.
The gravity assist was successful, and you're well on your way to the Venus refuelling station. During the rush
back on Earth, the fuel management system wasn't completely installed, so that's next on the priority list.
Opening the front panel reveals a jumble of wires. Specifically, two wires are connected to a central port and extend outward on a grid. You trace the
path each wire takes as it leaves the central port, one wire per line of text (your puzzle input).
Opening the front panel reveals a jumble of wires. Specifically, two wires are connected to a central port and
extend outward on a grid. You trace the path each wire takes as it leaves the central port, one wire per line of
text (your puzzle input).
The wires twist and turn, but the two wires occasionally cross paths. To fix the circuit, you need to find the intersection point closest to the central
port. Because the wires are on a grid, use the Manhattan distance for this measurement. While the wires do technically cross right at the central port
where they both start, this point does not count, nor does a wire count as crossing with itself.
The wires twist and turn, but the two wires occasionally cross paths. To fix the circuit, you need to find the
intersection point closest to the central port. Because the wires are on a grid, use the Manhattan distance for
this measurement. While the wires do technically cross right at the central port where they both start, this point
does not count, nor does a wire count as crossing with itself.
For example, if the first wire's path is R8,U5,L5,D3, then starting from the central port (o), it goes right 8, up 5, left 5, and finally down 3:
For example, if the first wire's path is R8,U5,L5,D3, then starting from the central port (o), it goes right 8, up
5, left 5, and finally down 3:
...........
...........
@@ -38,7 +41,8 @@ Advent of Code
.o-------+.
...........
These wires cross at two locations (marked X), but the lower-left one is closer to the central port: its distance is 3 + 3 = 6.
These wires cross at two locations (marked X), but the lower-left one is closer to the central port: its distance
is 3 + 3 = 6.
Here are a few more examples:
@@ -49,16 +53,19 @@ Advent of Code
What is the Manhattan distance from the central port to the closest intersection?
Your puzzle answer was 258.
--- Part Two ---
It turns out that this circuit is very timing-sensitive; you actually need to minimize the signal delay.
To do this, calculate the number of steps each wire takes to reach each intersection; choose the intersection where the sum of both wires' steps is
lowest. If a wire visits a position on the grid multiple times, use the steps value from the first time it visits that position when calculating the
total value of a specific intersection.
To do this, calculate the number of steps each wire takes to reach each intersection; choose the intersection
where the sum of both wires' steps is lowest. If a wire visits a position on the grid multiple times, use the
steps value from the first time it visits that position when calculating the total value of a specific
intersection.
The number of steps a wire takes is the total number of grid squares the wire has entered to get to that location, including the intersection being
considered. Again consider the example from above:
The number of steps a wire takes is the total number of grid squares the wire has entered to get to that location,
including the intersection being considered. Again consider the example from above:
...........
.+-----+...
@@ -71,11 +78,11 @@ Advent of Code
.o-------+.
...........
In the above example, the intersection closest to the central port is reached after 8+5+5+2 = 20 steps by the first wire and 7+6+4+3 = 20 steps by the
second wire for a total of 20+20 = 40 steps.
In the above example, the intersection closest to the central port is reached after 8+5+5+2 = 20 steps by the
first wire and 7+6+4+3 = 20 steps by the second wire for a total of 20+20 = 40 steps.
However, the top-right intersection is better: the first wire takes only 8+5+2 = 15 and the second wire takes only 7+6+2 = 15, a total of 15+15 = 30
steps.
However, the top-right intersection is better: the first wire takes only 8+5+2 = 15 and the second wire takes only
7+6+2 = 15, a total of 15+15 = 30 steps.
Here are the best steps for the extra examples from above:
@@ -86,6 +93,8 @@ Advent of Code
What is the fewest combined steps the wires must take to reach an intersection?
Your puzzle answer was 12304.
Both parts of this puzzle are complete! They provide two gold stars: **
At this point, you should return to your Advent calendar and try another puzzle.
@@ -109,6 +118,7 @@ References
. https://adventofcode.com/2019/leaderboard
. https://adventofcode.com/2019/stats
. https://adventofcode.com/2019/sponsors
. https://tretton37.com/join
. https://en.wikipedia.org/wiki/Taxicab_geometry
. https://adventofcode.com/2019
. https://adventofcode.com/2019/day/3/input