I was wondering if someone could explain to me how to approach this question as I am quite confused.

An online portal requires a user login with a password which must be from $6$ to $8$ characters long, where each character is a lowercase letter or a digit. A password must contain at least $1$ digit. How many possible passwords are there?

Thank you :)

  • 2
    $\begingroup$ Hint: first, ignore the condition on the digit. Can you solve the problem then? Next, count those with no digits. Subtract. $\endgroup$ – lulu Oct 9 '16 at 11:53

Let's look at cases. The password is $6$, $7$ or $8$ characters long.

Case 1. Say the password is $6$ characters long. We have $26$ lowercase letters to choose from and $10$ digits to choose from. Therefore we have $26+10=36$ selections for each slot in our password. By the rule of product this means we have $36^6$ total possibilities for our password. But we are concerned with passwords that have at least one digit and surely some of these in our total have no digits.

To remove the passwords with no digits let's total the number of no-digit $6$ character passwords we have, which is $26^6$. Then there are $36^6-26^6$ passwords with at least one digit (for more on this principle https://brilliant.org/wiki/principle-of-inclusion-and-exclusion-pie/).

Now, figure out case Case 2 ($7$ character password) and Case 3 ($8$ character password) similarly in the same fashion and add together the result of all three cases, this is your solution. We add these events because they are mutually exclusive (i.e. you may not have a $6$ character password and also a $7$ character password at the same time, if unfamiliar with this principle: https://brilliant.org/wiki/rule-of-sum/).


Let's count the number of passwords of size $k$ that consist a combination of lowercase letters and digits with at least one digit.

We know that for each char in the password we have $10 + 26 =36$ possible chars ($10$ different digits, and $26$ different lower letters). So the total passwords of size $k$ are $36^k$ - for each char out of $k$ chars we have $36$ different possibilities. But not all passwords consist at least one digit, we'll count those - each char in the password must be a lowercase letter- so there are $26^k$ such passwords.

Combining those results we get that the number of passwords of size $k$ that have at least one digit is $36^k - 26^k$.

In, our case, we just need to sum the disjoint cases of passwords of size $6,7,8$ and get that the number of such passwords is $$ 36^6 - 26^6 + 36^7 - 26^7 + 36^7 - 26^7 $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.