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?
- One digit used = 1 combination
- Two digits used = 14 combinations = 2^4-2
- Three digits used = ? combinations
- 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
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!