From e80e4613a49128d3475e358ec9e8ecd51dda482c Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 4 Dec 2019 12:22:27 +0000 Subject: [PATCH] Added some problem texts --- problems/day03.html | 176 ++++++++++++++++++++++++++++++++++++++++++++ problems/day04.html | 143 +++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 problems/day03.html create mode 100644 problems/day04.html diff --git a/problems/day03.html b/problems/day03.html new file mode 100644 index 0000000..d7227c9 --- /dev/null +++ b/problems/day03.html @@ -0,0 +1,176 @@ + + + + +Day 3 - Advent of Code 2019 + + + + + + + +

Advent of Code

Neil Smith (AoC++) 8*

   sub y{2019}

+ + + +
+

--- 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.

+

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.

+

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:

+
...........
+...........
+...........
+....+----+.
+....|....|.
+....|....|.
+....|....|.
+.........|.
+.o-------+.
+...........
+
+

Then, if the second wire's path is U7,R6,D4,L4, it goes up 7, right 6, down 4, and left 4:

+
...........
+.+-----+...
+.|.....|...
+.|..+--X-+.
+.|..|..|.|.
+.|.-X--+.|.
+.|..|....|.
+.|.......|.
+.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.

+

Here are a few more examples:

+
    +
  • R75,D30,R83,U83,L12,D49,R71,U7,L72
    U62,R66,U55,R34,D71,R55,D58,R83
    = distance 159
  • +
  • R98,U47,R26,D63,R33,U87,L62,D20,R33,U53,R51
    U98,R91,D20,R16,D67,R40,U7,R15,U6,R7
    = distance 135
  • +
+

What is the Manhattan distance from the central port to the closest intersection?

+
+

Your puzzle answer was 1225.

--- 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.

+

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 = 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.

+

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
  • +
+

What is the fewest combined steps the wires must take to reach an intersection?

+
+

Your puzzle answer was 107036.

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.

+

If you still want to see it, you can get your puzzle input.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file diff --git a/problems/day04.html b/problems/day04.html new file mode 100644 index 0000000..6ea5e77 --- /dev/null +++ b/problems/day04.html @@ -0,0 +1,143 @@ + + + + +Day 4 - Advent of Code 2019 + + + + + + + +

Advent of Code

Neil Smith (AoC++) 8*

   0x0000|2019

+ + + +
+

--- Day 4: Secure Container ---

You arrive at the Venus fuel depot only to discover it's protected by a password. The Elves had written the password on a sticky note, but someone threw it out.

+

However, they do remember a few key facts about the password:

+
    +
  • It is a six-digit number.
  • +
  • The value is within the range given in your puzzle input.
  • +
  • Two adjacent digits are the same (like 22 in 122345).
  • +
  • Going from left to right, the digits never decrease; they only ever increase or stay the same (like 111123 or 135679).
  • +
+

Other than the range rule, the following are true:

+
    +
  • 111111 meets these criteria (double 11, never decreases).
  • +
  • 223450 does not meet these criteria (decreasing pair of digits 50).
  • +
  • 123789 does not meet these criteria (no double).
  • +
+

How many different passwords within the range given in your puzzle input meet these criteria?

+
+

Your puzzle answer was 1955.

--- Part Two ---

An Elf just remembered one more important detail: the two adjacent matching digits are not part of a larger group of matching digits.

+

Given this additional criterion, but still ignoring the range rule, the following are now true:

+
    +
  • 112233 meets these criteria because the digits never decrease and all repeated digits are exactly two digits long.
  • +
  • 123444 no longer meets the criteria (the repeated 44 is part of a larger group of 444).
  • +
  • 111122 meets the criteria (even though 1 is repeated more than twice, it still contains a double 22).
  • +
+

How many different passwords within the range given in your puzzle input meet all of the criteria?

+
+

Your puzzle answer was 1319.

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.

+

Your puzzle input was 134792-675810.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file -- 2.34.1