Here's the question:
How many six-character passwords can be built with lowercase letters and numbers, given that at least one of its characters is a number?
Here's my answer:
$$10\dbinom{6}{1}36^5$$
- $10$ for the number possible choices for digits
- $\binom{6}{1}$ where one location in the $6$-character string is being chosen for the digit to be placed
- $36^5$ for remaining character combinations ($26$ letters + $10$ digits)
Here's the actual answer:
$$36^6 - 26^6$$
- $36^6$ for all strings of length $6$
- minus $26^6$ for the number of strictly alphabetical passwords
I get why the solution works, but I can't see where my solution went wrong; it's quite a bit bigger than the answer. Can someone explain why my answer is wrong?
The number of passwords with exactly $k$ digits is $$\binom{6}{k}10^k26^{6 - k}$$ since there are $10$ choices for each of the $k$ digits, $26$ choices for each of the $6 - k$ lowercase letters, and $\binom{6}{k}$ ways to select $k$ of the $6$ positions in the password for the letters to appear. Hence, the number of passwords with at least one digit is \begin{align*} \sum_{k = 1}^{6} \binom{6}{k}10^k26^{6 - k} & = \binom{6}{1} 10^1 26^5 + \binom{6}{2} 10^2 26^4 + \binom{6}{3} 10^3 26^3 + \binom{6}{4} 10^4 26^2\\ & \qquad + \binom{6}{5} 10^5 26^1 + \binom{6}{6} 10^6 26^0\\ & = 36^6 - 26^6 \end{align*} as you can verify.
By designating a particular digit as the digit that appears in the password, you count each password with $k$ digits $k$ times, once for each way you could designate one of the digits as the digit that appears in the password. For instance, the password 1a2b3c is counted three times, once when you designate 1 as the digit that appears in the password, once when you designate the 2 as the digit that appears in the password, and once when you designate 3 as the digit that appears in the password. Notice that \begin{align*} \sum_{k = 1}^{6} \color{red}{k}\binom{6}{k}10^k26^{6 - k} & = 1\binom{6}{1} 10^1 26^5 + \color{red}{2}\binom{6}{2} 10^2 26^4 + \color{red}{3}\binom{6}{3} 10^3 26^3 + \color{red}{4}\binom{6}{4} 10^426^2\\ & \qquad + \color{red}{5}\binom{6}{5} 10^5 26^1 + \color{red}{6}\binom{6}{6} 10^6 26^0\\ & = \color{red}{10\binom{6}{1}36^5} \end{align*}