# Number of 6-character passwords containing at least one number - why is my answer wrong?

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?

$$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)

$$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?

• Good to see I am not the only who was frustrated with Combinatorics due to logical fallacies like these (I had EXACTLY the same approach and confusion). Taussig's and gt6989b's answer restored my confidence back. Commented Nov 1, 2019 at 10:11

For example, the string 11AAAA is counted twice in your solution, once when your "minimum guaranteed digit" is the first one, and once -- when it is the second one...

• Thanks. I am too dumb to understand NF Taussig's mathematical answer, your explain it so nicely and simply with an example (Failing to understand it was frustrating). Commented Nov 1, 2019 at 10:04
• @Thokchom that answer goes much farther in explaining how to really solve the problem. I just explained what was wrong with OP's solution. Thanks for the kind words Commented Nov 1, 2019 at 16:09

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*}

When exactly one number is used, the total number of passwords $$=^{10}P_1 \times ^{26}P_5=7893600$$

When exactly two number are used, the total number of passwords $$=^{10}P_2 \times ^{26}P_4=3229200$$

When exactly three number are used, the total number of passwords $$=^{10}P_3 \times ^{26}P_3=1123200$$

When exactly four number are used, the total number of passwords $$=^{10}P_4 \times ^{26}P_2=3276000$$

When exactly five number are used, the total number of passwords $$=^{10}P_5 \times ^{26}P_1=786240$$

When all six characters used are numbers, the total number of passwords $$=^{10}P_6 \times ^{26}P_0=151200$$

Therefore, the total number of different passwords with the given conditions is;

$$7893600+3229200+1123200+3276000+786240+151200=16459440$$ passwords.

• Your count is incorrect since you have not chosen the positions of the digits within the passwords. Commented Oct 13, 2019 at 10:10