[Math] Count the number of possible passwords given that they consist of a combination of $6-8$ lowercase letters and digits with at least one digit

combinatoricsdiscrete mathematics

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 🙂

Best Answer

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/).