Our escape room recently acquired some old lockers with a couple of these combination padlocks on them. Unfortunately, the seller didn't know the code.

Is there a mathematical system in cycling through the possible solutions? The code is 5 of the numbers between 0 and 9. The order of the numbers doesn't matter and each number can only appear once, which should narrow it down a lot.

enter image description here

  • $\begingroup$ There are 15120 possible combinations if no number repeats. Otherwise, there are 387420489 of them. $\endgroup$ – Napoleon of Puzzling Dec 21 '17 at 14:58
  • $\begingroup$ I suppose you could start by trying to analyse which keys seem more worn out, or seem to have more fingerprints, or just seem softer to press. That might give you a starting point in narrowing down which numbers are more likely to be a part of the combination. Once you can narrow those down to 5, it's a very simple process to try different combinations of those numbers $\endgroup$ – HugoBDesigner Dec 21 '17 at 14:59
  • $\begingroup$ @NapoleonofPuzzling Is it really that many? Even when considering that there's no difference between 12345 and 54321? $\endgroup$ – Ravn Dec 21 '17 at 15:01
  • 6
    $\begingroup$ If the order does not matter, then there are only $10!/(5!^2)=252$ possibilities. That should be easy to cycle through in twenty minutes or so. $\endgroup$ – Jaap Scherphuis Dec 21 '17 at 15:04
  • 1
    $\begingroup$ If my understanding is correct, 5 keys must be down for the lock to open up. That narrows your possibilities down quite significantly, and if my hand-made combination sequences are accurate enough, it'll be only 128 different combinations to go through: pastebin.com/RZxQkqen $\endgroup$ – HugoBDesigner Dec 21 '17 at 15:12

Because we want to choose 5 of 10 digits, there will be $${10 \choose 5} = \frac{10!}{5!5!} = 252$$ possibilities.

Now the fun part is how do we do the bruteforce? To minimize the time taken, we can arrange the combinations in such a way that the different digit between each two combinations is only 1 (e.g. after 01234 then can be 01235 or 91234.)

Using lexicographical order doesn't satisfy it as 01239 will goes to 01243 (it changed 2 digits.) To make it efficient, I have written a simple program that generate a possible sequence of 252 combination such that the different digit between each two combinations is only 1.

The program is here: program

And the result is here: result

Some excerpts:

1: 56789
2: 46789
3: 45789
4: 45689
5: 45679
6: 45678
7: 35678
8: 35679
9: 35689
10: 35789
11: 36789
12: 34789
13: 34689
14: 34679
15: 34678
16: 34578
17: 34579
18: 34589
19: 34569
20: 34568
21: 34567
22: 24567
23: 24569

Bonus: If above list doesn't open the lock, then maybe it's not 5 of 10. Can be 4 of 10 or 6 of 10. In that case, update the value of N in my program and run it. For example, using #define N 4.

I guess, changing exactly one digit (therefore "pushing" two digits -- push out removed digit, pushed in new digit) and test the lock requires around 3 seconds. Therefore the time taken will be $252 \times 3 \approx 13~minutes$.

| improve this answer | |
  • 1
    $\begingroup$ After cycling through all 252 5-digit combinations and 192 of the 210 4-digit combinations, the first of the two locks finally opened (0157 was the code)! Thank you so much for the help, that program was amazingly helpful! $\endgroup$ – Ravn Dec 22 '17 at 12:38

I too have one of these locks. But after going the all possible 4 digit combinations I was unable to get it open. The lock can be disassembled while still locked. By tapping on the backs of the pins, the front panel will come off. Once the is apart, you'll notice there is a slight difference in the position on the notch on 4 of the 10 pins. This is how I determined the code was 2357 for my lock. Now you have the option to keep the original code of change it by simply relocating the pins.

| improve this answer | |
  • $\begingroup$ Actually, in some cheap locks the keys which are not part of the code act as a no-op (i.e. pressing them does nothing). So technically you can open the lock by pressing all 10 keys at once. $\endgroup$ – trolley813 Mar 21 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.