# How many 8-character passwords are there if at least one of each A-Z, a-z, and 0-9 are used?

How many 8-character passwords are there if each character is either A-Z, a-z, or 0-9, and where at least one character of each of the three types is used?

The complement of "at least one of each" is "either A-Z, a-z, or 0-9 is NOT used"

I defined a set $\left\lvert A\right\rvert=62^8$, all possible passwords. I then defined three more sets: $B$ - those passwords without A-Z, $C$ - those passwords without a-z, and $D$ - those passwords without 0-9.

$$\left\lvert B\right\rvert = 36^8,\quad \left\lvert C\right\rvert=36^8,\quad\mbox{ and } \left\lvert D\right\rvert = 52^8$$

Then by counting the complement, $\left\lvert A\right\rvert - \left\lvert B\cup C\cup D\right\rvert = \left\lvert A\right\rvert-\left\lvert B\right\rvert-\left\lvert C\right\rvert-\left\lvert D\right\rvert + \left\lvert B\cap C\right\rvert + \left\lvert B\cap D\right\rvert + \left\lvert C\cap D\right\rvert$.

$\left\lvert B\cup C\right\rvert ={}$Those without A-Z and without a-z ${}= 10^8$, etc.

Therefore I got $$62^8 - 36^8 - 36^8 - 52^8+ 10^8 + 26^8 + 26^8$$ as the answer.

Not sure if I counted my sets right, please let me know!

-

Depends on whether order matters or not. Are you allowed to have numbers and letter repeat etc etc. That will dictate on whether you are going to use a permutations or a combination.

-
No restrictions - order doesn't matter & repetition allowed –  user64025 Feb 27 '13 at 19:28
Bump to Cameron –  EhBabay Feb 27 '13 at 19:43
@user64025 Order doesn't matter? That's not in line with how real world passwords work. Are you sure? 'password' and 'wordpass' should count as different passwords. –  alex.jordan Jan 27 at 6:30
If order matters (so that $12345678$ and $87654321$ would be different passwords, for example) and repetition is allowed, then you've done it exactly right.
If order doesn't matter, and repetition is allowed, then we need to proceed differently. We'll need one each from the capital letters, the lower case letters, and the digits, with the other $5$ chosen from the general pool. Hence, the total number in that case is $$26\cdot 26\cdot 10\cdot 62^5.$$
If we don't allow repetition, and order doesn't matter, then we have $$\binom{26}{1}\cdot\binom{26}{1}\cdot\binom{10}{1}\cdot\binom{59}{5}$$ options.