I am trying to practice some combinatorics problems before my discrete mathematics test, and I came up with the problem that I tried solving and would like to know if I am working in the correct path.
How many passwords can we make following these rules:
The length of the password must be exactly $8$ characters and the password must contain at least one digit and no more than $3$ digits (Only normal letters and digits are allowed).
Here is what I tried:
We have $26$ letters {$a,...,z$} and $10$ digits {$0,...,9$}.. with no restrictions, there are ${36}\choose{8}$ ways to choose the characters and arrange them in 8! ways.
Now to follow the question, we have 3 different cases that we need to calculate:
$7$ letters and $1$ digits ${26}\choose{7}$$*$${10}\choose{1}$ ways to choose them and then arrange them in $7!$
$6$ letters and $2$ digits ${26}\choose{6}$$*$${10}\choose{2}$ ways to choose them and then arrange them in $6!*2!$
$5$ letters and $3$ digits ${26}\choose{5}$$*$${10}\choose{3}$ ways to choose them and then arrange them in $5!*3!$
Final answer: We add the 3 cases together
Am I correct or is this answer $26^7*10^1+26^6*10^2+26^5*10^3$ correct, and why/what's the difference and when is each used?
A better attempt considers the 8 positions in the password, and split the problem into three disjoint cases: exactly $i$ digits where $i=1,2,3$.
To get every password with $i$ digits and $8-i$ lowercase letters, we pick the positions where the digits are going to come, in $\binom{8}{i}$ ways. At each of these positions we have 10 possibilities that we can choose independently, so $10^i$ options for those positions, and finally $26^{8-i}$ options for the remaining positions.
So in total we get $$\binom{8}{1}\cdot 10^1 \cdot 26^7 + \binom{8}{2}\cdot 10^2 \cdot 26^6 + \binom{8}{3}\cdot 10^3 \cdot 26^5$$
as the total number of passwords.