description.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. --- Day 20: Grove Positioning System ---
  2. It's finally time to meet back up with the Elves. When you try to contact them, however, you get no reply. Perhaps you're out of range?
  3. You know they're headed to the grove where the star fruit grows, so if you can figure out where that is, you should be able to meet back up with them.
  4. Fortunately, your handheld device has a file (your puzzle input) that contains the grove's coordinates! Unfortunately, the file is encrypted - just in case the device were to fall into the wrong hands.
  5. Maybe you can decrypt it?
  6. When you were still back at the camp, you overheard some Elves talking about coordinate file encryption. The main operation involved in decrypting the file is called mixing.
  7. The encrypted file is a list of numbers. To mix the file, move each number forward or backward in the file a number of positions equal to the value of the number being moved. The list is circular, so moving a number off one end of the list wraps back around to the other end as if the ends were connected.
  8. For example, to move the 1 in a sequence like 4, 5, 6, 1, 7, 8, 9, the 1 moves one position forward: 4, 5, 6, 7, 1, 8, 9. To move the -2 in a sequence like 4, -2, 5, 6, 7, 8, 9, the -2 moves two positions backward, wrapping around: 4, 5, 6, 7, 8, -2, 9.
  9. The numbers should be moved in the order they originally appear in the encrypted file. Numbers moving around during the mixing process do not change the order in which the numbers are moved.
  10. Consider this encrypted file:
  11. 1
  12. 2
  13. -3
  14. 3
  15. -2
  16. 0
  17. 4
  18. Mixing this file proceeds as follows:
  19. Initial arrangement:
  20. 1, 2, -3, 3, -2, 0, 4
  21. 1 moves between 2 and -3:
  22. 2, 1, -3, 3, -2, 0, 4
  23. 2 moves between -3 and 3:
  24. 1, -3, 2, 3, -2, 0, 4
  25. -3 moves between -2 and 0:
  26. 1, 2, 3, -2, -3, 0, 4
  27. 3 moves between 0 and 4:
  28. 1, 2, -2, -3, 0, 3, 4
  29. -2 moves between 4 and 1:
  30. 1, 2, -3, 0, 3, 4, -2
  31. 0 does not move:
  32. 1, 2, -3, 0, 3, 4, -2
  33. 4 moves between -3 and 0:
  34. 1, 2, -3, 4, 0, 3, -2
  35. Then, the grove coordinates can be found by looking at the 1000th, 2000th, and 3000th numbers after the value 0, wrapping around the list as necessary. In the above example, the 1000th number after 0 is 4, the 2000th is -3, and the 3000th is 2; adding these together produces 3.
  36. Mix your encrypted file exactly once. What is the sum of the three numbers that form the grove coordinates?
  37. Your puzzle answer was 4914.
  38. --- Part Two ---
  39. The grove coordinate values seem nonsensical. While you ponder the mysteries of Elf encryption, you suddenly remember the rest of the decryption routine you overheard back at camp.
  40. First, you need to apply the decryption key, 811589153. Multiply each number by the decryption key before you begin; this will produce the actual list of numbers to mix.
  41. Second, you need to mix the list of numbers ten times. The order in which the numbers are mixed does not change during mixing; the numbers are still moved in the order they appeared in the original, pre-mixed list. (So, if -3 appears fourth in the original list of numbers to mix, -3 will be the fourth number to move during each round of mixing.)
  42. Using the same example as above:
  43. Initial arrangement:
  44. 811589153, 1623178306, -2434767459, 2434767459, -1623178306, 0, 3246356612
  45. After 1 round of mixing:
  46. 0, -2434767459, 3246356612, -1623178306, 2434767459, 1623178306, 811589153
  47. After 2 rounds of mixing:
  48. 0, 2434767459, 1623178306, 3246356612, -2434767459, -1623178306, 811589153
  49. After 3 rounds of mixing:
  50. 0, 811589153, 2434767459, 3246356612, 1623178306, -1623178306, -2434767459
  51. After 4 rounds of mixing:
  52. 0, 1623178306, -2434767459, 811589153, 2434767459, 3246356612, -1623178306
  53. After 5 rounds of mixing:
  54. 0, 811589153, -1623178306, 1623178306, -2434767459, 3246356612, 2434767459
  55. After 6 rounds of mixing:
  56. 0, 811589153, -1623178306, 3246356612, -2434767459, 1623178306, 2434767459
  57. After 7 rounds of mixing:
  58. 0, -2434767459, 2434767459, 1623178306, -1623178306, 811589153, 3246356612
  59. After 8 rounds of mixing:
  60. 0, 1623178306, 3246356612, 811589153, -2434767459, 2434767459, -1623178306
  61. After 9 rounds of mixing:
  62. 0, 811589153, 1623178306, -2434767459, 3246356612, 2434767459, -1623178306
  63. After 10 rounds of mixing:
  64. 0, -2434767459, 1623178306, 3246356612, -1623178306, 2434767459, 811589153
  65. The grove coordinates can still be found in the same way. Here, the 1000th number after 0 is 811589153, the 2000th is 2434767459, and the 3000th is -1623178306; adding these together produces 1623178306.
  66. Apply the decryption key and mix your encrypted file ten times. What is the sum of the three numbers that form the grove coordinates?
  67. Your puzzle answer was 7973051839072.