Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
I know my comment is way late, but I just saw this today. Recently I wrote a Monte Carlo simulator to evaluate passwords rules. It can be easily configured to fit a variety of criteria. I adjusted it to your criteria and pseudo-randomly generated 10,000,000 passwords. I used Maxima to evaluate your answer, and obtained 1.5965591136768*10^14 I ran my simulator and obtained 1.598e+14, which agrees with your answer to 3 significant digits. So your analysis appears to be correct. Congrats! – O.C.Riley Aug 17 '14 at 17:53

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.

share|cite|improve this answer
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 '14 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.

I don't want to deal with the case that we don't have repetition and order matters unless I have to, but let me know if that's the circumstance.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.