[Math] How many 8-character passwords are possible using one of each of three types of character possible

combinatorics

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

I believe this question is about using the technique of 'counting the complement'. The complement of "one character of each" is "either uppercase, lowercase, or digits is NOT used".

Total possible passwords : $62^8$

Total possible passwords w/ out uppercase letters: $36^8$

Total possible passwords w/ out lowercase letters: $36^8$

Total possible passwords w/ out digits : $52^8$

I think my trouble is from fully understanding what the 'complement' means. From what I understand it is (very loose explanation) the opposite of the restriction placed on our original set. So in our case the original set is $62^8$ and the complement of the restriction placed on that set, one of each character, is all the possibilities where types of characters are not there. Which are what I typed above this paragraph. However, I feel like I am missing something. Otherwise I would say that the answer is: $62^8 – [36^8 + 36^8 + 52^8]$.

Main problem: Not understanding how to compute the complement.

Best Answer

As Matt commented, we are using the principle of inclusion-exclusion. Note that your expression so far: $$62^8 - [36^8 + 36^8 + 52^8]$$ is actually too small; you oversubtracted. This is because certain passwords were double counted. For example, consider the illegal password: $ABCDEFGH$. Certainly, this is a possible password (it belongs to the set of size $62^8$). However, it contains no lowercase letters (it belongs to one of the sets of size $36^8$), so it is subtracted. However, notice that it contains no digits (it belongs to the set of size $52^8$), so it is subtracted a second time. This is bad! This illegal password is being counted a total of $1-2=-1$ times!

To compensate, we must add some back in. Note that:

  • Total possible passwords without uppercase AND without digits: $26^8$
  • Total possible passwords without lowercase AND without digits: $26^8$
  • Total possible passwords without uppercase AND without lowercase: $10^8$

Returning to our example illegal password $ABCDEFGH$, notice that it contains no lowercase AND no digits (it belongs to one of the sets of size $26^8$), so it is added back in once. This is good! This illegal password is now counted a total of $1-2+1=0$ times in our final answer.

Hence, our total should actually be: $$62^8 - [36^8 + 36^8 + 52^8] + [26^8 + 26^8 + 10^8] = 159655911367680$$

EDIT: As Goos mentioned, we would normally continue this pattern by subtracting out the passwords without uppercase AND without lowercase AND without digits. In this case, however, this set has size $0^8$, so this doesn't affect the answer.