challenge.txt 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. --- Day 23: Crab Cups ---
  2. The small crab challenges you to a game! The crab is going to mix up some cups, and you have to predict where they'll end up.
  3. The cups will be arranged in a circle and labeled clockwise (your puzzle input). For example, if your labeling were 32415, there would be five cups in the circle; going clockwise around the circle from the first cup, the cups would be labeled 3, 2, 4, 1, 5, and then back to 3 again.
  4. Before the crab starts, it will designate the first cup in your list as the current cup. The crab is then going to do 100 moves.
  5. Each move, the crab does the following actions:
  6. The crab picks up the three cups that are immediately clockwise of the current cup. They are removed from the circle; cup spacing is adjusted as necessary to maintain the circle.
  7. The crab selects a destination cup: the cup with a label equal to the current cup's label minus one. If this would select one of the cups that was just picked up, the crab will keep subtracting one until it finds a cup that wasn't just picked up. If at any point in this process the value goes below the lowest value on any cup's label, it wraps around to the highest value on any cup's label instead.
  8. The crab places the cups it just picked up so that they are immediately clockwise of the destination cup. They keep the same order as when they were picked up.
  9. The crab selects a new current cup: the cup which is immediately clockwise of the current cup.
  10. For example, suppose your cup labeling were 389125467. If the crab were to do merely 10 moves, the following changes would occur:
  11. -- move 1 --
  12. cups: (3) 8 9 1 2 5 4 6 7
  13. pick up: 8, 9, 1
  14. destination: 2
  15. -- move 2 --
  16. cups: 3 (2) 8 9 1 5 4 6 7
  17. pick up: 8, 9, 1
  18. destination: 7
  19. -- move 3 --
  20. cups: 3 2 (5) 4 6 7 8 9 1
  21. pick up: 4, 6, 7
  22. destination: 3
  23. -- move 4 --
  24. cups: 7 2 5 (8) 9 1 3 4 6
  25. pick up: 9, 1, 3
  26. destination: 7
  27. -- move 5 --
  28. cups: 3 2 5 8 (4) 6 7 9 1
  29. pick up: 6, 7, 9
  30. destination: 3
  31. -- move 6 --
  32. cups: 9 2 5 8 4 (1) 3 6 7
  33. pick up: 3, 6, 7
  34. destination: 9
  35. -- move 7 --
  36. cups: 7 2 5 8 4 1 (9) 3 6
  37. pick up: 3, 6, 7
  38. destination: 8
  39. -- move 8 --
  40. cups: 8 3 6 7 4 1 9 (2) 5
  41. pick up: 5, 8, 3
  42. destination: 1
  43. -- move 9 --
  44. cups: 7 4 1 5 8 3 9 2 (6)
  45. pick up: 7, 4, 1
  46. destination: 5
  47. -- move 10 --
  48. cups: (5) 7 4 1 8 3 9 2 6
  49. pick up: 7, 4, 1
  50. destination: 3
  51. -- final --
  52. cups: 5 (8) 3 7 4 1 9 2 6
  53. In the above example, the cups' values are the labels as they appear moving clockwise around the circle; the current cup is marked with ( ).
  54. After the crab is done, what order will the cups be in? Starting after the cup labeled 1, collect the other cups' labels clockwise into a single string with no extra characters; each number except 1 should appear exactly once. In the above example, after 10 moves, the cups clockwise from 1 are labeled 9, 2, 6, 5, and so on, producing 92658374. If the crab were to complete all 100 moves, the order after cup 1 would be 67384529.
  55. Using your labeling, simulate 100 moves. What are the labels on the cups after cup 1?
  56. Your puzzle answer was 52864379.
  57. The first half of this puzzle is complete! It provides one gold star: *
  58. --- Part Two ---
  59. Due to what you can only assume is a mistranslation (you're not exactly fluent in Crab), you are quite surprised when the crab starts arranging many cups in a circle on your raft - one million (1000000) in total.
  60. Your labeling is still correct for the first few cups; after that, the remaining cups are just numbered in an increasing fashion starting from the number after the highest number in your list and proceeding one by one until one million is reached. (For example, if your labeling were 54321, the cups would be numbered 5, 4, 3, 2, 1, and then start counting up from 6 until one million is reached.) In this way, every number from one through one million is used exactly once.
  61. After discovering where you made the mistake in translating Crab Numbers, you realize the small crab isn't going to do merely 100 moves; the crab is going to do ten million (10000000) moves!
  62. The crab is going to hide your stars - one each - under the two cups that will end up immediately clockwise of cup 1. You can have them if you predict what the labels on those cups will be when the crab is finished.
  63. In the above example (389125467), this would be 934001 and then 159792; multiplying these together produces 149245887792.
  64. Determine which two cups will end up immediately clockwise of cup 1. What do you get if you multiply their labels together?
  65. Answer:
  66. Your puzzle input is still 318946572.