Combinatorics – Solving an Unusual Combination Lock Problem

combinatoricspermutations

Suppose there's a 4-digit combination padlock and you're asked to open it.

But this lock has an unique defect in a way that the four digits need not be in the correct order for it to open. For example, if the right key is 0-1-2-3, combinations such as 3-2-1-0, 2-0-1-3 or any other orderings of 0, 1, 2, 3 are sufficient to crack it open.

  1. How many tries does it take to open this lock with brute force?
  2. What is the best strategy to ensure the least number of tries?

(edit) Yes, let's assume repetition of digits is allowed.

Best Answer

If repetition of digits is not allowed, then @anorton's answer does it. If repeated digits are allowed, then imagine 9 bars: $$|||||||||$$ Between successive bars you have areas that represent a digit: $$0|1|2|3|4|5|6|7|8|9$$ You need to put the four digits from the combination into these 10 areas. For example, 0-1-2-3 can be represented as: $$*|*|*|*||||||$$ and 1-2-2-9 as: $$|*|**|||||||*$$ Any arrangement of 9 bars and 4 stars provides you with a unique combination (since order is ignored). Thus with 13 things to set as either a star or a bar, and the requirement that four of them must be stars, there are $\binom{13}{4}=715$ possibilities.