Possible Password Combinations with Requirements

combinationscombinatoricspermutations

I'm trying to find the number of password combinations that are exactly 6 characters long using:

  • lower case letters (a-z, total: 26)
  • upper case letter (A-Z, total : 26)
  • numbers (0-9, total: 10)
  • special characters (~`!@#$%^&*()_-+={[}]|:;"'<,>.?/ , total: 32)

the password must consist of at least 1 character from the 4 categories.

I've tried using inclusion/exclusion such as getting the number of combinations when there is no requirements which equals $(26+26+32+10)^6$ and taking away the password combinations that don't satisfy the requirements, but have tried many times with no definitive end product.

Another strategy I've tried using is consider that my password has to have one character form each category and then 2 remaining characters from any category equalling $26 \times 26 \times 32 \times 10 \times 94 \times 94$ and then arranging them by multiplying by $6!$, but the end result of this number is much larger than if there were no requirements.

Help would be much appreciated.

Best Answer

Inclusion Exclusion generalizes well. However, for this particular problem, the numbers are small enough that a direct approach is straightforward.

Since there are only 2 extra positions of wiggle room, the distribution must be one of two (mutually exclusive) forms: 3,1,1,1 or 2,2,1,1. So, you simply compute each distribution separately and then add them together.


$\underline{\text{3,1,1,1}}.$

First, you want to reserve a factor of $~6 \times 5 \times 4 = 120.~$ That is, there are $~6~$ ways of positioning the first singleton, then $~5~$ ways of positioning the next singleton, and then $~4~$ ways of positioning the 3rd singleton. Then, the triplet takes the remaining slots.

Then, with positioning accounted for, the number of different selections of characters possible is :

$$A = \\ [(32)^3 \times (26) \times (26) \times (10)] + [(32) \times (26)^3 \times (26) \times (10)] \\ + [(32) \times (26) \times (26)^3 \times (10)] + [(32) \times (26) \times (26) \times (10)^3].$$

So, the total for this case is

$$120A.$$


$\underline{\text{2,2,1,1}}.$

First, you want to reserve a factor of $~6 \times 5 \times 6 = 180.~$ That is, there are $~6~$ ways of positioning the first singleton, then $~5~$ ways of positioning the next singleton, and then $~6~$ ways of positioning the 1st pair. Then, the 2nd pair takes the remaining slots.

Then, with positioning accounted for, the number of different selections of characters possible is :

$$B = \\ [(32)^2 \times (26)^2 \times (26) \times (10)] + [(32)^2 \times (26) \times (26)^2 \times (10)] \\ + [(32)^2 \times (26) \times (26) \times (10)^2] + [(32) \times (26)^2 \times (26)^2 \times (10)] \\ + [(32) \times (26)^2 \times (26) \times (10)^2] + [(32) \times (26) \times (26)^2 \times (10)^2].$$

So, the total for this case is

$$180B.$$


$\underline{\text{Final Total}}$

$$120A + 180B.$$