[Math] Number of various 7 character passwords that are required to contain a number and symbol

combinatorics

In this question on Information Security, different options are given for passwords. One example states that a password contains a mixture of numbers, letters and special characters.

Assuming that there are 52 letters, 10 numbers and 20 special characters, how many passwords would be possible assuming each password was required to have at least 1 number, letter, and special.

The leading answer lists that 52^10 would be the combinations in 10 letter password, but assuming it was required to have at least 1 of each case what would the number of possible passwords be?

Best Answer

Given an alphabet $V$ consisting of $52$ letters, $10$ numbers and $20$ special characters, we are looking for the number of different words of length $7$ containing at least one letter, one number and one special character.

We count the wanted words by calculating the number of all words of length $7$ built from the alphabet $V$ and subtract those which contain only one type or precisely two different types of characters.

  • The number of different words of length $7$ built from characters from $V$ is $$|V|^7=(52+10+20)^7=82^7$$

  • The number of different words containing precisely one type of characters is \begin{align*} 52^7+10^7+20^7 \end{align*}

  • The number of different words containing precisely two types of characters is \begin{align*} \sum_{k=1}^6\binom{7}{k}\left(52^k\cdot 10^{7-k}+52^k\cdot 20^{7-k}+10^k\cdot 20^{7-k}\right) \end{align*} The first term $\sum_{k=1}^6\binom{7}{k}52^k\cdot 10^{7-k}$ is the number of possibilities to place $52$ letters and $10$ numbers at $7$ places where at least one letter and at least one number occurs. The other summands are interpreted analogously.

We obtain the number of wanted words: \begin{align*} &82^7-\left(52^7+10^7+20^7\right)-\sum_{k=1}^6\binom{7}{k}\left(52^k\cdot 10^{7-k}+52^k\cdot 20^{7-k}+10^k\cdot 20^{7-k}\right)\\ &\quad=12383811148800 \end{align*}

in accordance with the result of @N.F.Taussig.