# The code of a student is a sequence consisting of 6 characters…

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?

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$$).
• 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? – Murad Sh-ov Feb 11 at 20:42
• 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). – JMoravitz Feb 11 at 20:45
• 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? – Murad Sh-ov Feb 12 at 9:31