Number of combinations: $4$ digits, no repeating and $2$ and $5$ must occur

combinatorics

Following problem:

You are creating a $4$-digit pin code. How many choices are there if no digit is repeated and the digits $2$ and $5$ must be present?

My approach was $(1 \cdot 1 \cdot 8 \cdot 7) \cdot 4! = 1344$, but the solution is ${8\choose2} \cdot 4! = 672$.

The solution notes "Pick two additional digits and count all permutations", as well as "these must be chosen in an unordered fashion, since we later count all $4!$ permutations of the unordered digits", but I don't understand the approach. I don't understand why we use the binomial coefficient instead of simply counting $8 \cdot 7$.

Best Answer

There are two options for doing this problem. You can either place the digits or you can select the digits and then arrange them.

In your attempt, you effectively placed the two digits, then arranged them.

Placing the digits: There are four ways to place the $2$ and three ways to place the $5$ in one of the three remaining positions. There are eight ways to fill the first open position with one of the remaining digits and seven ways to fill the final open position with one of the remaining digits. Hence, there are $$4 \cdot 3 \cdot 8 \cdot 7 = 672$$ $4$-digit pin codes with distinct digits that include both a $2$ and a $5$.

Selecting the digits: You must select both $2$ and $5$. You must also select two of the remaining eight digits, which can be done in $\binom{8}{2}$ ways. Once you have selected the four digits which are to be used, you can arrange the selected digits in $4!$ ways, giving $$\binom{2}{2}\binom{8}{2}4! = 672$$ $4$-digit pin codes with distinct digits that include both a $2$ and a $5$.

Why is your approach wrong?

In your approach, you imposed an order on the selection of the additional digits by selecting the first additional digit in eight ways and the second additional digit in seven ways. If you select $3$ as your first additional digit and then $4$ as your second additional digit, your method gives $4!$ ways to arrange the digits $2, 3, 4, 5$. However, if you were to select $4$ as the first additional digit and $3$ as the second additional digit, your method also gives $4!$ arrangements of the digits $2, 3, 4, 5$. You only want to count such arrangements once. By selecting the additional digits in order, you end up counting each admissible arrangement twice.