2
$\begingroup$

A spy encounters a keypad that requires a 4 digit PIN. He uses a fine dust to find which keys are used in the combination. He does not know the sequence of keys, nor which ones repeat if any. Obviously if only 3 keys are required one of them is repeated. If 2 keys are required then either 2 keys are repeated twice, or 1 key repeated three times.

The puzzle is for me to design a pin which makes the spies job as hard as possible. Are 4 unique keys the safest, or is have one or more repeating keys better?

  1. One digit used = 1 combination
  2. Two digits used = 14 combinations = 2^4-2
  3. Three digits used = ? combinations
  4. Four digits used = ? combinations

Can someone do the math and come up with the possible combinations that use exactly 3 and 4 keys, no more or less. My intuition is that the repeating keys will increase the number of combinations more than used all 4 keys for the pin.

PS. For the two digits (if they are X, Y) then the combinations are:

XXXY, XXYX, XXYY, 
XYXX, XYXY, XYYX, XYYY, 
YXXX, YXXY, YXYX, YXYY, 
YYXX, YYXY, YYYX

Related link Combinations: security code with no defined start and finish

$\endgroup$
  • 4
    $\begingroup$ Tell the folks that when entering the code, they should always press on a few random keys as well. This way the spy can't figure out which keys below to the code! Muhahaha. $\endgroup$ – Asaf Karagila Apr 10 '13 at 17:04
  • $\begingroup$ I once lived in a building with a keypad-activated lock at the main entrance, which had a peculiar characteristic: it beeped when each key was pressed, at a frequency that depended on the key pressed. So your typical spy could dispense with the fine dust... $\endgroup$ – TonyK Apr 10 '13 at 17:21
  • $\begingroup$ @AsafKaragila - and gloves haven't been invented yet. $\endgroup$ – ja72 Apr 10 '13 at 20:02
  • $\begingroup$ @ja72: It's too hot for gloves in Israel. :-) $\endgroup$ – Asaf Karagila Apr 10 '13 at 20:17
3
$\begingroup$

If four digits are used, the number of possibilities is simply 4! = 24.

If three digits are used, and we know which digit is used twice, then there are 4!/2 = 12 possibilities. But we don't know which digit is used twice, so we must multiply that by 3 to get 36 possibilities.

So your intuition is correct!

$\endgroup$
  • 1
    $\begingroup$ Can you elaborate a little more on the logic. I don't quite follow on how you arrive at $4!$ and $\frac{3}{2}4!$. $\endgroup$ – ja72 Apr 10 '13 at 20:06

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.