Piotr Czajkowski vor 7 Stunden
Ursprung
Commit
1cb49a0e22
1 geänderte Dateien mit 70 neuen und 0 gelöschten Zeilen
  1. 70 0
      02/description.txt

+ 70 - 0
02/description.txt

@@ -0,0 +1,70 @@
+
+You ride the train to its first stop: a large farm surrounded by fields. The Elves explain that you're not actually here for anything the farm grows; apparently, this farm also collects thunder from passing storms. This explains the surprisingly rumbly crates being loaded onto the train.
+
+In an attempt to distance yourself from the noise, you take a walk and explore some of the farm. After a few minutes, you come across some Elves tinkering with an interesting-looking robot.
+
+From a brief conversation, you learn that the robot's job is to follow a long series of colorful waypoints, automatically watering, fertilizing, and weeding as it travels. The Elves are trying to figure out how far the robot's current program will take it.
+
+The waypoints appear in a repeating pattern of six colors: red (r), orange (o), yellow (y), green (g), blue (b), and violet (v). The robot starts at a red waypoint. So, the first few waypoints look like this:
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv...
+The robot has a program (your puzzle input) which tells it which color of waypoint to go to next. The robot always goes to the very next waypoint of the indicated color. So, if the robot were at a red waypoint, an instruction of o would cause it to travel a distance of 1 (to the waypoint directly in front of it), while an instruction of r would cause it to travel a distance of 6 before it found the next red waypoint.
+
+For example, using ^ to mark the robot's current position, suppose the robot had a program of obbvb:
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+^ initial robot position
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+ ^ robot travels distance 1 to next orange waypoint
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+    ^ robot travels distance 3 to next blue waypoint
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+          ^ robot travels distance 6 to next blue waypoint
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+           ^ robot travels distance 1 to next violet waypoint
+
+roygbvroygbvroygbvroygbvroygbvroygbvroygbvroygbv
+                ^ robot travels distance 5 to next blue waypoint
+After these instructions, the robot has traveled a total distance of 16.
+
+Here are a few more examples:
+
+A robot with program roygbv would travel a total distance of 11.
+A robot with program vbgyor would travel a total distance of 30.
+A robot with program vvvvvv would travel a total distance of 35.
+However, the robot's actual program is much longer. Starting at a red waypoint, what distance would the program cause the robot to travel?
+
+Your puzzle answer was 3315.
+
+--- Part Two ---
+
+Unfortunately, you've confirmed the Elves' suspicions: this program simply won't take the robot far enough.
+
+The Elves would just give the robot a longer program, but some of the keys on their keyboard are broken, so they can't type the letters they need. The only thing they can do is rearrange the colors in the existing program.
+
+However, they do know a trick for making the robot travel long distances. Whenever the robot is about to move, it should always get the instruction that would cause it to move the furthest. So, if the robot is at an orange waypoint, it would be best if the robot's next instruction were o (for distance 6); if there aren't any o instructions left, the next-best instruction would be r (for distance 5), and so on.
+
+So, your job is to rearrange the colors in the robot's program so that each color causes the robot to move as far as possible. For example, suppose the robot had an initial program of rybryb:
+
+The robot starts at a red waypoint.
+The first instruction in the rearranged program could be r (distance 6), y (distance 2), or b (distance 4), so the first instruction should be r.
+The next instruction could again be r (distance 6), y (distance 2), or b (distance 4), so the next instruction should be r.
+Next, there are no more r instructions left to use; the options are y (distance 2) or b (distance 4). So, the next instruction should be b.
+Now, the options are b (distance 6) or y (distance 4), so the next instruction should again be b.
+Finally, the only instructions left are all y, so the last two instructions will both be y (distance 4, then distance 6).
+So, the program rybryb could be rearranged into rrbbyy, giving a total distance of 32.
+
+Here are a few more examples:
+
+The program vrvbvg could be rearranged into rvvvbg, a total distance of 33.
+The program groovyyoyo could be rearranged for a total distance of 55.
+The program roygbvroygbvroygbv could be rearranged for a total distance of 103.
+Use the Elves' trick to rearrange the instructions in the program. Starting at a red waypoint, what distance would the rearranged program cause the robot to travel?
+
+Your puzzle answer was 5407.
+
+Both parts of this puzzle are complete! They provide two gold stars: **