description.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --- Day 13: Claw Contraption ---
  2. Next up: the lobby of a resort on a tropical island. The Historians take a moment to admire the hexagonal floor tiles before spreading out.
  3. Fortunately, it looks like the resort has a new arcade! Maybe you can win some prizes from the claw machines?
  4. The claw machines here are a little unusual. Instead of a joystick or directional buttons to control the claw, these machines have two buttons labeled A and B. Worse, you can't just put in a token and play; it costs 3 tokens to push the A button and 1 token to push the B button.
  5. With a little experimentation, you figure out that each machine's buttons are configured to move the claw a specific amount to the right (along the X axis) and a specific amount forward (along the Y axis) each time that button is pressed.
  6. Each machine contains one prize; to win the prize, the claw must be positioned exactly above the prize on both the X and Y axes.
  7. You wonder: what is the smallest number of tokens you would have to spend to win as many prizes as possible? You assemble a list of every machine's button behavior and prize location (your puzzle input). For example:
  8. Button A: X+94, Y+34
  9. Button B: X+22, Y+67
  10. Prize: X=8400, Y=5400
  11. Button A: X+26, Y+66
  12. Button B: X+67, Y+21
  13. Prize: X=12748, Y=12176
  14. Button A: X+17, Y+86
  15. Button B: X+84, Y+37
  16. Prize: X=7870, Y=6450
  17. Button A: X+69, Y+23
  18. Button B: X+27, Y+71
  19. Prize: X=18641, Y=10279
  20. This list describes the button configuration and prize location of four different claw machines.
  21. For now, consider just the first claw machine in the list:
  22. Pushing the machine's A button would move the claw 94 units along the X axis and 34 units along the Y axis.
  23. Pushing the B button would move the claw 22 units along the X axis and 67 units along the Y axis.
  24. The prize is located at X=8400, Y=5400; this means that from the claw's initial position, it would need to move exactly 8400 units along the X axis and exactly 5400 units along the Y axis to be perfectly aligned with the prize in this machine.
  25. The cheapest way to win the prize is by pushing the A button 80 times and the B button 40 times. This would line up the claw along the X axis (because 80*94 + 40*22 = 8400) and along the Y axis (because 80*34 + 40*67 = 5400). Doing this would cost 80*3 tokens for the A presses and 40*1 for the B presses, a total of 280 tokens.
  26. For the second and fourth claw machines, there is no combination of A and B presses that will ever win a prize.
  27. For the third claw machine, the cheapest way to win the prize is by pushing the A button 38 times and the B button 86 times. Doing this would cost a total of 200 tokens.
  28. So, the most prizes you could possibly win is two; the minimum tokens you would have to spend to win all (two) prizes is 480.
  29. You estimate that each button would need to be pressed no more than 100 times to win a prize. How else would someone be expected to play?
  30. Figure out how to win as many prizes as possible. What is the fewest tokens you would have to spend to win all possible prizes?
  31. Your puzzle answer was 26810.
  32. The first half of this puzzle is complete! It provides one gold star: *
  33. --- Part Two ---
  34. As you go to win the first prize, you discover that the claw is nowhere near where you expected it would be. Due to a unit conversion error in your measurements, the position of every prize is actually 10000000000000 higher on both the X and Y axis!
  35. Add 10000000000000 to the X and Y position of every prize. After making this change, the example above would now look like this:
  36. Button A: X+94, Y+34
  37. Button B: X+22, Y+67
  38. Prize: X=10000000008400, Y=10000000005400
  39. Button A: X+26, Y+66
  40. Button B: X+67, Y+21
  41. Prize: X=10000000012748, Y=10000000012176
  42. Button A: X+17, Y+86
  43. Button B: X+84, Y+37
  44. Prize: X=10000000007870, Y=10000000006450
  45. Button A: X+69, Y+23
  46. Button B: X+27, Y+71
  47. Prize: X=10000000018641, Y=10000000010279
  48. Now, it is only possible to win a prize on the second and fourth claw machines. Unfortunately, it will take many more than 100 presses to do so.
  49. Using the corrected prize coordinates, figure out how to win as many prizes as possible. What is the fewest tokens you would have to spend to win all possible prizes?