|
| 1 | +## \--- Day 13: Claw Contraption --- |
| 2 | + |
| 3 | +Next up: the [lobby](https://adventofcode.com/2020/day/24) of a resort on a tropical island. The Historians take a moment to admire the hexagonal floor tiles before spreading out. |
| 4 | + |
| 5 | +Fortunately, it looks like the resort has a new [arcade](https://en.wikipedia.org/wiki/Amusement_arcade)! Maybe you can win some prizes from the [claw machines](https://en.wikipedia.org/wiki/Claw_machine)? |
| 6 | + |
| 7 | +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. |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +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. |
| 12 | + |
| 13 | +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: |
| 14 | + |
| 15 | +``` |
| 16 | +Button A: X+94, Y+34 |
| 17 | +Button B: X+22, Y+67 |
| 18 | +Prize: X=8400, Y=5400 |
| 19 | +
|
| 20 | +Button A: X+26, Y+66 |
| 21 | +Button B: X+67, Y+21 |
| 22 | +Prize: X=12748, Y=12176 |
| 23 | +
|
| 24 | +Button A: X+17, Y+86 |
| 25 | +Button B: X+84, Y+37 |
| 26 | +Prize: X=7870, Y=6450 |
| 27 | +
|
| 28 | +Button A: X+69, Y+23 |
| 29 | +Button B: X+27, Y+71 |
| 30 | +Prize: X=18641, Y=10279 |
| 31 | +``` |
| 32 | + |
| 33 | +This list describes the button configuration and prize location of four different claw machines. |
| 34 | + |
| 35 | +For now, consider just the first claw machine in the list: |
| 36 | + |
| 37 | +- Pushing the machine's `A` button would move the claw `94` units along the `X` axis and `34` units along the `Y` axis. |
| 38 | +- Pushing the `B` button would move the claw `22` units along the `X` axis and `67` units along the `Y` axis. |
| 39 | +- 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. |
| 40 | + |
| 41 | +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. |
| 42 | + |
| 43 | +For the second and fourth claw machines, there is no combination of A and B presses that will ever win a prize. |
| 44 | + |
| 45 | +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. |
| 46 | + |
| 47 | +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`. |
| 48 | + |
| 49 | +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? |
| 50 | + |
| 51 | +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?_ |
| 52 | + |
| 53 | +Your puzzle answer was `[REDACTED]`. |
| 54 | + |
| 55 | +The first half of this puzzle is complete! It provides one gold star: ⭐ |
| 56 | + |
0 commit comments