Password Help (combinations/permutations)

67 Views Asked by At

Much appreciated if someone can tell me if I did these correctly or not;

Repetition is allowed. 26 Capital, 26 Lowercase, 10 Number, 32 Special Characters

1) Question: 8 Characters long, must include 1 capital, 1 number.

Answer: (any 8 characters) - (no caps) - (no digits) + (neither caps or digits) = $(26+26+10+32)^8 - (26+10+32)^8 - (26+26+32)^8 + (26+32)^8 = 3.237 \times 10^{15}$

2) Question: 8 Characters long, must include 1 capital, 1 lowercase, 1 number, 1 special character (only 3 total special characters are accepted)

Answer: (any 8 characters) - (no caps) - (no lowercase) - (no digits) - (no special characters) + (neither caps, lower, number, or special char) = $(26+26+10+3)^8 - (26+10+3)^8 - (26+10+3)^8 - (26+26+3)^8 - (26+26+10)^8 + (0)^8 = 5.866 \times 10^{12}$

If those answers are correct, why would question #2 be a smaller number than #1?

1

There are 1 best solutions below

8
On BEST ANSWER

Part 1 is correct.

Part 2 is not because you didn't actually use the requirement that there be exactly 1-3 special characters.

Regardless, the correct answer of #2 is clearly less than that of #1: all passwords that fulfill the requirements of #2 also fulfill the requirements of #1. Thus the set of passwords for #2 is a subset of those for #1.

Inclusion-exclusion is going to get pretty ugly when you need to count 0,1,2,3,4 special characters, so split them:

(number of ways to choose 1 character out of 8) $\times$ (strings of 1 special character) $\times$ (strings of 7 characters using only capitals/lowercase/numbers, with at least 1 capital, 1 lowercase, 1 number)

$+$

(number of ways to choose 2 characters out of 8) $\times$ (strings of 2 special characters) $\times$ (strings of 6 characters using only capitals/lowercase/numbers, with at least 1 capital, 1 lowercase, 1 number)

$+$

repeat for 3 special characters.

That you can do.

Additionally, inclusion-exclusion for three sets $A,B,C$ is more complicated: $$|A\cup B\cup C|=|A|+|B|+|C|-|A\cap B|-|A\cap C|-|B\cap C|+|A\cap B\cap C|$$ You need to properly include all multi-way intersections, so "no caps nor lowercase", for example, is missing.