A password must be $6$ characters long and contain only digits and lower-case English letters. How many different passwords start with a digit or end with a letter?

I was only given the answer as $(10 \cdot 36^5) + (26 \cdot 36^5) - (10 \cdot 26 \cdot 36^4)$.

Please explain this to me as soon as possible.


closed as off-topic by samerivertwice, Brian Borchers, Namaste, Tom-Tom, cansomeonehelpmeout Apr 24 '18 at 20:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – samerivertwice, Brian Borchers, Namaste, Tom-Tom, cansomeonehelpmeout
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ The stated answer is incorrect. There should be a negative sign before the third term. Also, please explain what you do not understand. $\endgroup$ – N. F. Taussig Apr 24 '18 at 16:03
  • $\begingroup$ I understood the 3rd term but I do not understand why did they subtract 3rd term from 1st and 2nd. Moreover from where did the first two terms come from $\endgroup$ – min Li Apr 24 '18 at 16:07
  • 1
    $\begingroup$ The key phrase you are probably being exposed to here is inclusion-exclusion (a topic for which an exercise like this would reinforce learning). $\endgroup$ – hardmath Apr 24 '18 at 18:12

Consider the following $6$ empty spaces: __ __ __ __ __ __

You want to 'fill them up' with letters or numbers. Notice there are $26$ letters in the alphabet and $10$ digits to choose from.

$(1)$ If you want to the password to start with a number, you can pick the first space to be 'filled' with any digit from $0$ to $9,$ so in $10$ possible ways. Since the rest doesn't matter for the condition to be fulfilled, any subsequent space can be filled with a number or a letter of which we have $26+10=36 $ total. So we have $10 \cdot 36^5$ total combinations that start with a number.

$(2)$ If you want the password to end with a letter, for the last space pick any of the $26$ letters available. For the other spaces pick any of the $36$ numbers or letters.So we have $26 \cdot 36^5$ total combinations that end with a letter.

However, notice that there are some combinations that start with a number and end with a letter. If we just sum up $(1)+(2)$ we would be counting these combinations twice (once every time we consider $(1)$ and another time when we consider $(2)$) so we have to subtract a set of these combinations, which is given by $10 \cdot 36^4 \cdot 26$ because of the same arguments as above. Hence the final result will be $$10 \cdot 36^5\ +\ 26 \cdot 36^5\ -\ 10 \cdot 36^4 \cdot 26.$$

  • Start with a digit: $10\times 36^5$ passwords

  • End with a letter: $26\times 36^5$ passwords

  • Start with a digit AND end with a letter: $10\times 36^4\times 26$ passwords

The passwords in the third group are included twice in the first and second groups, so the correct answer is: $10\times 36^5+ 26\times 36^5-10 \times 36^4\times 26.$

The answer you provided is incorrect, so you may find it difficult to understand.

Venn AeqB

You might want to draw a Venn diagram that consists of two circles intersect each other, $A$ for "start with a digit", $B$ for "end with a letter", the shared part is for "start with a digit AND end with a letter" and ignore the "empty set" symbol.


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