Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose you want to generate a password using ASCII characters ($128$ characters.)How many ways can you create a password of 10 characters long that has at least one lowercase letter (a-z) and at least one number ($0-9$)?

** MY ANSWER: $26*10*(128)^{10}$**

I don't understand why this is wrong? Can anybody help? Thanks!

share|cite|improve this question
Your answer is the amount of passwords you could generate that starts with a lower case letter, followed by a number, followed by 10 other ASCII characters. So, it's a string of length 12, and you don't take into consideration the different permutations. – kba Dec 17 '12 at 3:50
ASCII characters 0 through 31 are control characters, so for practicality you would never use these in a password. Same goes for 127, the delete character. And character 32 is the space character, which is questionable in a password. So if this is not just an exercise, you might want to limit your available characters to 94 0r 95. – alex.jordan Dec 17 '12 at 7:08

The easiest way is to count all the passwords, then deduct those that don't meet the requirement. There are $128^{10}$ total passwords, ignoring the requirement for a lower case letter and a number. Of those $(128-26)^{10}$ have no lower case letter and $(128-10)^{10}$ have no number. But we have deducted twice those that have no lower case letter and no digit-an example of the inclusion-exclusion principle. So we add them back in-there are $(128-36)^{10}$ of those. So the final answer is $128^{10}-102^{10}-118^{10}+92^{10}=578747468760442009600$ per Alpha$

share|cite|improve this answer
Is the power of 12 correct? – Amzoti Dec 17 '12 at 5:05
@Amzoti: No, I was fixing it while you looked. – Ross Millikan Dec 17 '12 at 5:06

It is easiest to concentrate first on the bad strings, the ones that do not qualify. These are the strings that are missing a lower-case letter, or a number, or both.

There are $102^{10}$ strings with no lower-case letters, and $118^{10}$ with no numbers. However, if we add these two numbers we are double-counting the words that miss both letter and number. There are $92^{10}$ of these. It follows that there are $102^{10}+118^{10}-92^{10}$ bad strings. Thus the number of good strings is $$128^{10}-102^{10}-118^{10}+92^{10}.$$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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