Counting the number of passwords of length 6 with the given conditions

316 Views Asked by At

A password of length 6 with upper case letters, lower case letters and digits. Password must contain at least 1 upper case, 1 lower case and 1 digit. How many possible passwords are there ?

What I did. Total are $62^{6}$.

Passwords in which upper and lower are mixed(no digits) = $ 52^{6} - 2(26^{6})$.

Passwords in which upper and digits are mixed(no lower) = $ 36^{6} - 10^{6} - 26^{6}$.

Passwords in which lower and digits are mixed(no upper) = $ 36^{6} - 10^{6} - 26^{6}$.

I subtracted all these from the total so get $ 62^{6} - 52^{6} - 2(36^{6}) + 2(26^{6}) + 10^{6}$. Is this the correct way.

What other ways could one think about ?

1

There are 1 best solutions below

0
On

I just checked my final answer with that of the OP: are answers match. I simply had some trouble following the OP's logic, so I arrived at the same answer by a moderately different route:

Also, the alternative to Inclusion-Exclusion, which I will briefly describe, but do not advise using, would be a direct approach:

The number of digits used will either be $1,2,3,$ or $4$. In each of the 4 cases, you then have to enumerate how many of the remaining characters are uppercase vs lower case.

As an illustration:
In the case of 3 digits used, you will either have 1 uppercase or 2 uppercase. Exploring the specific case of 3 digits, 2 uppercase, and 1 lowercase, the enumeration would be:

There is $A = \binom{6}{1} \times \binom{5}{2}$ ways of positioning the digits, uppercase letters and lowercase letters.

Then, once the positions are set, there are $B = (10)^3 \times (26)^2 \times (26)^1$ different character assignments that can go in the corresponding positions in the password.

Therefore, the enumeration for this subcase is $A \times B.$

There may be a more elegant approach for the direct approach alternative to Inclusion Exclusion that is escaping me.

Anyway, in any event, Inclusion-Exclusion is much easier.


From Inclusion-Exclusion:

Let $T_k$ denote the number of ways that at least $k$ constraints are violated.

Then, you want $T_0 - T_1 + T_2 - T_3.$

$T_0 = (62)^6.$

To calculate $T_1$, there are 3 possibilities:
No uppercase, no lowercase, or no digits.

Therefore,
$T_1 = (36)^6 + (36)^6 + (52)^6.$

To calculate $T_2$, there are 3 possibilities:
No uppercase or lowercase, no uppercase or digits, no lowercase or digits.

Therefore
$T_2 = (10)^6 + (26)^6 + (26)^6.$

In considering $T_3$, it is impossible for all three constraints to be violated, because no characters are allowed except the 62 letters/numbers. The assumption that all 3 constraints are violated would mean that there were no characters available.

Therefore
$T_3 = 0.$