One Dead Button, 3,439 Missing Codes: The Locker Keypad's Hidden Arithmetic
Photo: Mutney, CC BY-SA 4.0, via Wikimedia Commons
At the leisure centre, the lockers have a four-digit keypad and one button — the 5 — that has gone sticky. Not dead exactly: sometimes it needs a firm press, sometimes it registers twice. Reception has taped a handwritten sign above the row: PLEASE AVOID THE 5. In one small physical defect, the locker has become a different mathematical object.
The multiplication principle in a swimming costume
Start with the clean case. A four-digit code uses digits 0 to 9, and repeats are allowed. Each of the four positions has 10 choices independently, so the total number of codes is
10 × 10 × 10 × 10 = 10^4 = 10,000.
This is the multiplication principle: when choices are independent, you multiply the number of options at each stage. If the 5 is unusable, each position has 9 choices instead of 10. The new total is
9^4 = 6,561.
That leaves 10,000 − 6,561 = 3,439 codes missing. Put another way, the fraction of codes containing at least one 5 is 1 − (9/10)^4, which is about 0.344. One sticky button removes roughly 34% of the code space, not 10%. It removes every code with a 5 anywhere.
When the keypad forbids repeats
Some lockers insist that the four digits are all different. Then the count changes. The first digit has 10 choices, the second has 9, the third has 8 and the fourth has 7:
10 × 9 × 8 × 7 = 5,040.
This is a permutation count, often written as 10P4. If the 5 is out of action and repeats are still forbidden, the count becomes
9 × 8 × 7 × 6 = 3,024.
The drop is 2,016 codes, or 40% of the no-repeat set. The no-repeat rule already makes the code space smaller; the sticky button takes a larger share of what remains.
A flaky button is messier than a dead one
The neat counts above assume you can simply avoid the 5. If the button is flaky, the algebra is less tidy. A press might produce no digit, or two digits, or the right digit after a delay. Then the keypad is no longer a simple product of independent choices. You have a mapping from intended codes to actual keypad entries, and you would need to count distinct outputs. That is a harder combinatorial problem, and it is exactly the sort of thing that makes real security engineering awkward.
Even so, the dead-button model is useful. It gives an upper bound on how much the defect can shrink the safe code space if users follow the sign and avoid the button entirely.
Bits of security
Security people sometimes measure a code space in bits. The number of bits is log base 2 of the number of possibilities. For the full four-digit keypad, log2(10,000) is about 13.3 bits. For the 5-free keypad, log2(6,561) is about 12.7 bits. The sticky button has removed roughly 0.6 bits. For the no-repeat case, log2(5,040) is about 12.3 bits, and log2(3,024) is about 11.6 bits, a loss of about 0.7 bits. One bit is a halving of the search space, so this is less than a halving, but it is not nothing.
None of this is an invitation to go guessing at lockers. Use them as intended, report faulty keypads, and do not leave anything valuable inside. The point is that a tiny physical defect rewrites the sample space. A locker code is not just a secret; it is a count.
Counting your own keypad
The general rule is simple. If a code has L positions and there are n usable digits, repeats allowed gives n^L codes. No repeats gives n × (n − 1) × … × (n − L + 1), as long as n is at least L. One sticky digit makes n = 9. Two sticky digits make n = 8, and a four-digit code falls to 8^4 = 4,096 with repeats, or 8 × 7 × 6 × 5 = 1,680 without. The losses compound because the choices at each position shrink together.
So the sticky 5 is more than an annoyance. It is a small lesson in combinatorics: change one button, and the locker becomes a smaller mathematical universe. The sign says PLEASE AVOID THE 5. The algebra says please adjust your estimate of how many codes are left.