The code of a student is a sequence consisting of 6 characters, each of which is either one of the 26 letters of the English alphabet or one of the digits 0,1,.......,9. How many codes are there which contain at most two digits?

I did it in this way, but i am not quite sure in my result.

We have 10 choises for choosing numbers and 26 for letters. Our code should contain at most 2 digits, so we have 4 letters left. Order matters, therefore we should handle this problem with help of permutations. Thus, (10 * 9) * (26 * 25 * 24 * 21) , where (10 * 9) is choises for choosing any number between 0 - 9 and (26 * 25 * 24 * 21) for choosing 4 letters among 26. Is this solution correct or i misunderstood something?

Thanks in advance.


You seem to be misunderstanding quite a bit. $(10\cdot 9)\cdot (26\cdot 25\cdot 24\cdot \color{red}{23})$ counts very specifically only those codes for students which have exactly two digits and furthermore those digits appear only at the front of the code. Furthermore, your calculations count only codes where there are no repeated characters which was not a requirement in the problem.

You have missed counting several cases such as where there are fewer than two digits (E.g. $1ABCDE$) as well as counting those codes where the digits don't necessarily appear at the very start (E.g. $A1B2CD$) and codes which have repeated characters (E.g. $AABBCC$).

As for a corrected approach, count how many ways you can have a code with no digits. Add this to the number of ways you can have a code with one digit. Finally, add this to the number of ways you can have a code with two digits. Do not forget to include in your calculations something to do with the positions used by the digits.

  • $\begingroup$ So, # of ways with no digits is $ 26^6 $, # of ways of code with one digit is $ 6 * 26^5 $, # of ways of code with two digits is$ 6^2 * 26^4 $. If previously mentioned expressions are right, then their sum: $ 26^6+6*26^5+6^2*26^4 $ sould be the result. Is it right now? $\endgroup$ – Murad Sh-ov Feb 11 at 20:42
  • $\begingroup$ Closer. With one digit, yes you'll choose where the digit goes in six ways and what the letters are in $26^5$ ways but you neglected to take into account which digit it was. For two digits there are not $6^2$ ways to choose where the digits go (note, you may not repeat a choice of location and order of choices don't matter). $\endgroup$ – JMoravitz Feb 11 at 20:45
  • $\begingroup$ For one digit, can we write C(10,1) to calculate which digit we took? I mean 6 * 26^5 * C(10,1) . $\endgroup$ – Murad Sh-ov Feb 11 at 21:54
  • $\begingroup$ I wouldn't bother using binomial coefficients for deciding which digit(s) is used. Just call it 10 $\endgroup$ – JMoravitz Feb 11 at 22:04
  • $\begingroup$ 3 cases: 1) no digit:$ 26^6 $ 2) 1 digit: 6 * $26^5$ * 10 3) 2 digits: 6 * 5 *$ 26^4$ * C(10+2-1,2) Are these calculations right now? $\endgroup$ – Murad Sh-ov Feb 12 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.