[Math] Possible password combinations with requirements.

combinatorics

I'm trying to calculate the number of possible password combinations when my password consists of 6 characters that can be

  • uppercase letters
  • lowercase letters
  • digits

I know that if there are no requirements, the amount of possible combinations equals $(26+26+10)^6$, but I am trying to satisfy for the requirement that there must be at least 1 uppercase character, at least 1 lowercase character, and at least 1 digit.

My strategy is to consider that my password can be of the form $(U,L,D,\star,\star,\star)$, with for $U$ and $L$ $26$ possibilities, for $D$ $10$ possibilities, and for $\star$ $62$ possibilities. Then, I only need to correct for their order, but I do not know how to do this.

Any possible steps to take would be very much appreciated.

Best Answer

Use inclusion/exclusio principle:

  • Include the total number of passwords: $(26+26+10)^6$
  • Exclude the number of passwords with no digits: $(26+26)^6$
  • Exclude the number of passwords with no lower-case: $(26+10)^6$
  • Exclude the number of passwords with no upper-case: $(26+10)^6$
  • Include the number of passwords with no lower-case or digits: $(26)^6$
  • Include the number of passwords with no upper-case or digits: $(26)^6$
  • Include the number of passwords with no lower-case or upper-case: $(10)^6$

The answer is therefore:

$$(26+26+10)^6-(26+26)^6-(26+10)^6-(26+10)^6+(26)^6+(26)^6+(10)^6$$