A five character code is required to open a safe consisting of 2 letters and 3 digits out of {a,b,c,d,e} letters and {1,2,3,4,5,6,7} digits. How many different codes with no repetition allowed can be formed if there are two specific digits which cannot be together in the code ?

My attempt :-

Let the two specific digits be 1 and 2

Case 1:- When both 1 and 2 are not present in the passcode

${5 \choose 2}*5*4*5*4*3$

So basically I selected 2 spaces out of 5 in the passcode, then 5 ways to assign first letter in one of these spaces and 4 ways to assign the 2nd letter. And afterwards, 5 ways to assign the first digit and 4 ways to assign the second digit, and 3 ways for 3rd digit

Case 2:- When 1 is definitely present in the passcode

${5 \choose 2}*5*4*1*5*4$

Case 3:- When 2 is definitely present in the passcode

${5 \choose 2}*5*4*1*5*4$

Total ways to form passcode = 20,000

Official answer = 300*5!

Please let me know the fault in my processing


1 Answer 1


In case 2, I see you did $\binom{5}{2}$. What was this for? Choosing the positions for the letters? Okay, now you multiplied by $5$, then by $4$ for choosing the letters that appeared. What happened next? You multiplied by $1$, as though the furthest left appearing digit must have been a $1$. Why did you not multiply this by $3$ to pick what position the $1$ was put in?

In doing so, noting that this implies all cases happen to be the same size we get for you a final answer of $\left(\binom{5}{2}\times 5\times 4\times 5\times 4\times 3\right)\times 3 = 36000$

For the books presumed approach: There are $\binom{5}{2}\binom{7}{3}=350$ ways to select two letters and three digits. Of these, there are $\binom{5}{2}\binom{5}{1}=50$ ways that had selected both of the troublesome digits. There are then $350-50=300$ ways to select your five characters such that it avoided both troublesome digits, and then $5!$ ways to arrange those.

This gives the official answer of $300\times 5! = 36000$

  • $\begingroup$ Ohhh yes ! Thank you :) and thanks for explaining the official solution as well ! $\endgroup$
    – Vasu Gupta
    Commented Jul 26, 2023 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .