diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:18:18 -0400 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-04-07 17:19:39 -0400 |
| commit | 87ab487d59fa85dbe2afa55cc841b02805ae42ca (patch) | |
| tree | cd90ab715e1b5b5803674045dbafd6d51d27ac90 /src/03/part2 | |
| parent | 1bcc82c5bfbde87edd03c01ffdf9ee5934681592 (diff) | |
| download | aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.tar.gz aoc2018-python-87ab487d59fa85dbe2afa55cc841b02805ae42ca.zip | |
Reorder days into src
Diffstat (limited to 'src/03/part2')
| -rw-r--r-- | src/03/part2 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/03/part2 b/src/03/part2 new file mode 100644 index 0000000..5764b53 --- /dev/null +++ b/src/03/part2 @@ -0,0 +1,44 @@ +--- Part Two --- + +It turns out that this circuit is very timing-sensitive; you actually need to [1m[97mminimize the signal +delay[0m. + +To do this, calculate the [1m[97mnumber of steps[0m each wire takes to reach each intersection; choose the +intersection where the [1m[97msum of both wires' steps[0m is lowest. If a wire visits a position on the grid +multiple times, use the steps value from the [1m[97mfirst[0m 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: + +........... +.+-----+... +.|.....|... +.|..+--X-+. +.|..|..|.|. +.|.-X--+.|. +.|..|....|. +.|.......|. +.o-------+. +........... + +In the above example, the intersection closest to the central port is reached after 8+5+5+2 = +[1m[97m20[0m steps by the first wire and 7+6+4+3 = [1m[97m20[0m steps by the second wire for a total of 20+20 = +[1m[97m40[0m steps. + +However, the top-right intersection is better: the first wire takes only 8+5+2 = [1m[97m15[0m and the second +wire takes only 7+6+2 = [1m[97m15[0m, a total of 15+15 = [1m[97m30[0m steps. + +Here are the best steps for the extra examples from above: + + + - R75,D30,R83,U83,L12,D49,R71,U7,L72 +U62,R66,U55,R34,D71,R55,D58,R83 = 610 steps + + - R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51 +U98,R91,D20,R16,D67,R40,U7,R15,U6,R7 = 410 steps + + +[1m[97mWhat is the fewest combined steps the wires must take to reach an intersection?[0m + + |
