1

Password length is either 5 or 6 characters long. Allowed characters are a-z, A-Z and 0-9. The password should have at least one character from a-z, at least one character from A-Z and at least one character from 0-9. How many legal passwords are there?

My answer: |a-z| + |A-Z| + |0-9| = 62 A_5 = D(62, 5 - 3) A_6 = D(62, 6 - 3)

Answer = |A_5| + |A_6|

Amy I correct?

Thanks

1 Answers1

0

Let us count the legal passwords of length $5$. If there were no restrictions, it would be $62^5$.

But some of these strings are bad. We count the bad strings of length $5$. There are $52^5$ strings with no digit. There are $36^5$ strings with nothing from A-Z. And there are $36^5$ with nothing from a-z.

If we add these three numbers, we will have double-counted the all digit words, the all caps word, and the all a-z words. There is a total of $10^5+26^5+26^5$ of these. Thus the number of bad strings of length $5$ is $$52^5+36^5+36^5-10^5-26^5-26^5.$$ Subtract from $62^5$ to get the number of legal passwords of length $5$.

Repeat for $6$ characters and add.

Remark: The fancy name for the idea we used is the Principle of Inclusion/Exclusion.

André Nicolas
  • 507,029