James Stanley


Prime Combination

You come across a 5-digit combination padlock. The combination is 10723. The padlock is currently showing 00001. If the combination is ever set to a number that is not prime, it resets to 00001 immediately, so every intermediate state from 00001 to 10723 also must be prime. How do you input the combination?

  • The input wheels are arranged in the usual way: 5 positions with digits 0 to 9, decrementing from 0 gets you to 9, incrementing from 9 gets you to 0.
  • There is a mechanism that prevents you from turning more than 1 wheel at a time.
  • If you try to park a digit halfway between 2 values it springs back to one of the values before you are able to change another digit.

I have posted a solution and some analysis.