Case 50 · shortest-path challenge · Hard · About 10-15 minutes
The archive elevator has a peculiar test mode. Its floor display works, but only three buttons respond. You start on floor 2 and want to reach floor 17 with as few button presses as possible. Each press changes the floor immediately according to a precise rule.
This is a mathematical machine, not a real elevator instruction. You can solve it with pencil and paper by listing reachable floors in rounds.

The test-mode rules
- U: add 4 to the current floor.
- D: subtract 3 from the current floor.
- X: double the current floor.
- Floors must stay between 0 and 30, inclusive. A move outside that range is forbidden.
- You may not press the same button twice in succession. You may use it again after a different button.
For example, from floor 2, pressing U then X takes you to 6 and then 12. Pressing X then X is forbidden, even though both resulting floors would be in range. All three buttons are available for the first move, subject to the floor limit.
What is the minimum number of presses needed to reach floor 17? Find a shortest button sequence. For an extra challenge, find every shortest sequence.
To prove a route is shortest, finding a route is only half the job. You must also rule out shorter ones. Track the last button as well as the current floor: being on floor 8 after U gives different next options from being on floor 8 after X.
Hint 1 - reveal when you want a nudge
Search in layers: one press, then two, then three. Do not begin by guessing a long route.
Hint 2 - reveal when you want a nudge
There are three shortest routes, each with five presses. Two begin with X; one begins with U.
Reveal the solution and explanation
The minimum is five presses. One shortest sequence is U, X, U, D, U. Its floor sequence is 2, 6, 12, 16, 13, 17. Every move stays within the allowed range, and adjacent buttons are different.
The other shortest sequences are X, U, X, U, D, giving 2, 4, 8, 16, 20, 17; and X, U, X, D, U, giving 2, 4, 8, 16, 13, 17. These are all three shortest routes.
Here is a reproducible shortestness check. Begin with the state (2, no previous button). At each round, apply every permitted button to every state in the previous round. Discard out-of-range moves and moves repeating the previous button. Keep both the new floor and the button just pressed. Floor 17 appears in none of rounds one through four. In round five, it appears on precisely the three sequences above.
You can audit the final step as well. To land on 17, the preceding floor must be 13 before U or 20 before D. X cannot land there because doubling a whole number gives an even number. The four-press routes that can make those legal final moves are UXUD, XUXD, and XUXU. This narrows the full search to the same three answers.
Solve another: The Cabinet of Fifty Mysteries · Browse all 50 cases


















