Find the number of three-character codes which may contain the digits 1 to 5, which can be reused, and the letters A to E, which can’t be reused. For example, 4B4 is an acceptable code, but BB4 is not. Show hint
There are lots of different ways to answer this question, depending on how we split it up into different cases. I’ll describe three ways here. The first way involves counting the number of codes made of all digits, adding the number of codes with one letter, two letter, three letters. The second way involves counting the number of codes that don’t reuse digits, then adding the number of codes that do reuse digits. The third way involves counting the number of codes there would be if we could reuse letters, then subtracting the number of codes with reused letters.
The number of codes with all digits is $5\times5\times5 = 125$. With the codes containing one letter, there are $5$ choices for the letter, then $5$ choices for the first digit, and $5$ choices for the second digit, and $3$ ways to position the letter amongst the digits, making $5\times5\times5\times3 = 375$ codes. (You may have thought that there would be $3!$ ways to arrange the letter and digits, but we’ve already arranged the digits and just need to choose if the letter goes at the start, middle, or end.) With the codes containing two letters, there are $5$ choices for the first letter, $4$ choices for the second letter, then $5$ choices for the digit, and $3$ ways to position the digit amongst the letters, making $5\times4\times5\times3 = 300$ codes. For the codes containing three letters, there are $^5P_3 = 5\times4\times3 = 60$ codes. So the total number of codes is:
$125$ | (all digits, e.g. 525) |
$+375$ | (one letter, e.g. 33A, 5C4) |
$+300$ | (two letters, e.g. CE1) |
$\underline{+\phantom{3}60}$ | (three letters, e.g. BDA) |
$=860$ |
Alternatively, we can start by finding out the number of codes that don’t reuse digits, then add on the ones that do. Without reusing digits, we have $^{10}P_3 = 10\times9\times8 = 720$ codes. Next we can count the number of codes that have a digit twice: $5$ choices for the repeated digit, then $9$ choices for the other character (one of the $5$ letters or $4$ remaining digits), then $3$ ways of arranging them, so $5\times9\times3 = 135$ codes. There are also $5$ codes that have the same digit repeated three times. So the total number of codes is:
$720$ | (no reused digits, e.g. 3B5, 412) |
$+135$ | (a digit twice, e.g. 33A, 525) |
$\underline{+\phantom{13}5}$ | (a digit three times, e.g. 555, 222) |
$=860$ |
Or we could work out the number of codes there would be if we could reuse letters, then subtract off the number of codes that shouldn’t have been counted. If we could reuse letters, then there would be $10\times10\times10=1000$ codes. The number of these codes that contain a letter repeated twice is $135$ (like in the previous solution), and then $5$ codes that contain the same letter three times. So the total is:
$1000$ | (can reuse anything, e.g. 2BB, A34, 111) |
$-135$ | (a letter twice, e.g. A3A, ECC) |
$\underline{-\phantom{13}5}$ | (a letter three times, e.g. DDD, AAA) |
$=860$ |