Recovering a lost combination

Sat 21 November 2015 | tags: python

I lost the combination to an old Master Lock of mine. Fortunately, figuring out the combination for my type of lock is a well-known process. Unfortunately, the previous link's method for finding the third value in the combination did not work for me, but I found instructions that were very helpful. Once the third value is found there is an algorithm to generate 80 possible combinations, which is where Python comes in.

Procedure outline

Only apply this method to locks for which you are the sole owner.

  1. Clear the lock by spinning the dial clockwise by three revolutions, ending with the dial set to zero.

  2. Rotate the dial through its twelve "sticking points" and find the non-fake sticking point. This non-fake point is the third value in the lock's combination.

  3. Once the third value is found, run the script that follows.

Sticking points

  • Sticking points occur when you pull up on the shackle and are only able to rotate the dial by approximately +/- 0.5.

  • Once you've found a sticking point, move to the next one by removing tension from the shackle. Rotate the dial slightly counter-clockwise so that the next sticking point will catch upon tensioning the shackle again.

A sticking point is likely fake if:

  • The dial pivots between two whole numbers (e.g., 20 and 21).

  • When you pull up super hard on the shackle the dial's rotation becomes limited. (When I successfully found my third value, the dial rotated by +/-0.5 freely regardless of how much tension I applied to the shackle.)

Python implementation

In [1]:
"""
1. First find the non-fake sticking point (the third value).
2. Enter the third_value below, then run the script.
3. Try each combination until the correct one is found.
"""
# ------------------------
# user-defined input
# ------------------------
# Find the third value manually, then assign it here.
third_value = 20

# ------------------------
# algorithm
# ------------------------
# Divide by 4 and store the remainder.  The remainder is called the
# "magic number"
magic_number = third_value % 4

# Compute the possible values for the first value.
first_values = [magic_number + 4 * i for i in xrange(10)]

# Compute the possible values for the second value.
if magic_number in [0, 1]:
    magic_number += 2
else:
    magic_number -= 2
second_values = [magic_number + 4 * i for i in xrange(10)]
# The two values closest to third_value can be eliminated.
second_values = [v for v in second_values if abs(third_value - v) > 2]

# Compute the possible combinations.
for n1 in first_values:
    for n2 in second_values:
        print('%d - %d - %d' % (n1, n2, third_value))
        # Uncomment the following line to pause the looping.
        # r = raw_input('continue ?')
0 - 2 - 20
0 - 6 - 20
0 - 10 - 20
0 - 14 - 20
0 - 26 - 20
0 - 30 - 20
0 - 34 - 20
0 - 38 - 20
4 - 2 - 20
4 - 6 - 20
4 - 10 - 20
4 - 14 - 20
4 - 26 - 20
4 - 30 - 20
4 - 34 - 20
4 - 38 - 20
8 - 2 - 20
8 - 6 - 20
8 - 10 - 20
8 - 14 - 20
8 - 26 - 20
8 - 30 - 20
8 - 34 - 20
8 - 38 - 20
12 - 2 - 20
12 - 6 - 20
12 - 10 - 20
12 - 14 - 20
12 - 26 - 20
12 - 30 - 20
12 - 34 - 20
12 - 38 - 20
16 - 2 - 20
16 - 6 - 20
16 - 10 - 20
16 - 14 - 20
16 - 26 - 20
16 - 30 - 20
16 - 34 - 20
16 - 38 - 20
20 - 2 - 20
20 - 6 - 20
20 - 10 - 20
20 - 14 - 20
20 - 26 - 20
20 - 30 - 20
20 - 34 - 20
20 - 38 - 20
24 - 2 - 20
24 - 6 - 20
24 - 10 - 20
24 - 14 - 20
24 - 26 - 20
24 - 30 - 20
24 - 34 - 20
24 - 38 - 20
28 - 2 - 20
28 - 6 - 20
28 - 10 - 20
28 - 14 - 20
28 - 26 - 20
28 - 30 - 20
28 - 34 - 20
28 - 38 - 20
32 - 2 - 20
32 - 6 - 20
32 - 10 - 20
32 - 14 - 20
32 - 26 - 20
32 - 30 - 20
32 - 34 - 20
32 - 38 - 20
36 - 2 - 20
36 - 6 - 20
36 - 10 - 20
36 - 14 - 20
36 - 26 - 20
36 - 30 - 20
36 - 34 - 20
36 - 38 - 20

Download this post's IPython notebook here.

Comments !

social