# Combinatorics question with locks.

I have a question regarding the following problem.

A crime detective is able to dust a lock for finger prints and he determines that the numbers: 3,4,5 and 8 have been pressed repeatedly and the other numbers have not. If the lock is a standard 10 digit number pad, and the combination contains 5 places, how many different possible password could he have to try before finding the correct one?

The following is my claim.

It is natural to think that the four numbers are pressed repeatedly, therefore each numbers are used at least once.

So, using the fundamental counting principle with 5 places, I would say the first number could be any of the 4 numbers.

This is where I get iffy.

The next number may or may not be the repetition of the previous, so I am not sure whether to call it 4 choices or 3 choices.

Ignoring my confidence, I think the answer is $4*4!$ which implies the fact that there are 24 combinations of numbers with 4 choices of numbers that could have been repeated.

What concerns me is the position of the repeated number, though.

I know that the combinations of the lock is sensitive to order, so I am not sure if the second number is repeated, third number is repeated, etc.... and I cannot tell numerically if that makes a difference or not.

Can I have some confirmation?

• There are 4! ways to arrange all the numbers that have been pressed, then there are 10 ways to pick the number we don't know. This gives us: 4!x10 = 240 different possible codes. – Dunka Feb 25 '15 at 4:02

You’re thinking about the right things, but not in quite the right way. The first thing to realize, as you did, is that since it’s a $5$-digit key that contains just $4$ distinct digits, exactly one of the digits must be repeated, and there are $4$ ways to choose that one. The next step — or at least what I find to be the most natural next step — is to count the ways to place those matched digits in the key. There are $5$ positions in the key, and we have to choose $2$ of them for the matched digits; we can do this in $\binom52$ ways. That leaves $3$ positions, which can be filled in any of $3!$ orders by the remaining $3$ digits. Thus, we come up with a total of
$$4\cdot\binom52\cdot3!=4\cdot10\cdot6=240$$
Your figure of $4\cdot4!$ can be interpreted in various ways. One of the most natural, though, is as follows. We first key in the $4$ digits in some order; that can be done in $4!$ ways. We then pick any one of the $4$ digits to fill in the fifth and last position. In other words, you counted the keys in which the repeated digit comes at the end, missing the ones in which it doesn’t.