# Number of $32$-character alphanumeric strings with certain conditions

I'm seeking a solution of one of the most complicated Math problem of my life.

Here it is :

First we need to figure out how many strings of set [a-zA-Z0-9] (Which is 26 Small Letters, 26 Capital Letters, and 0 to 9 digits] Are possible to construct of length 32 characters.

Then we need to subtract these 3 out of our result.

1. Possible 32 character strings which has only small letters. [a-z]
2. Possible 32 character strings which has only big letters. [A-Z]
3. Possible 32 character strings which has only digits. [0-9]

Let me know if any questions.

• Do you mean #(strings with at least one of the three types of characters)? Commented Feb 5, 2017 at 0:16
• YES. Apology if I made the problem sound more complicated. Commented Feb 5, 2017 at 0:17
• Example of strings are : yXgZxJsaRG8o7EBMCXknL6XFW7V9Smmg , x8k9Ifp9ejbEYzyt2TPdkZfY1T5fZNJm , C958NV3IN3m18jVBgrtBkWdSigaDVZao Commented Feb 5, 2017 at 0:18
• This is a nice question. What sorts of approaches have you considered? Commented Feb 5, 2017 at 0:19
• @dxiv I'm only ok at maths till a certain level. And this question is like puzzle of my life I can't figure out till now. Commented Feb 5, 2017 at 0:27

Please let me know if I have grossly misinterpreted the problem.

It seems clear to me that we are allowed to repeat letters and numbers. Then, for each slot in our $32$-character string, we have $62$ choices, adding all of the options together ($26$ letters, both upper and lower case, and the $10$ numbers).

Since there are $32$ characters and repetition is allowed, we come to $62^{32} = 2272657884496751345355241563627544170162852933518655225856$ possibilities. Good lord. According to Wolfram Alpha, that is roughly 43 million times the number of possible chess positions. Good lord.

For strings made entirely of capital letters, we have $26^{32}=1901722457268488241418827816020396748021170176$ possibilities. This is also true for the lowercase letters.

Similarly, there are $10^{32}=100000000000000000000000000000000$ possible $32$-element strings of just digits.

So, your answer, apparently, is $62^{32}-2(26)^{32}-10^{32} = 2272657884492947900440704487144706514530812140022612885504$.

• Well counted. Commented Feb 5, 2017 at 3:03
• @CarstenS Ah! Ah! Ah! Commented Feb 5, 2017 at 4:40

Let $U,L,D$ be the sizes of the sets of strings containing only uppercase letters (26 usable characters), lowercase letters (26) or digits (10) respectively. Then the number of admissible strings is $$62^{32}-U-L-D=62^{32}-2\cdot26^{32}-10^{32}$$ $$=2.272\dots×10^{57}$$

• I got the impression the OP just wanted to exclude strings of only capitals, only lowercase, and only numbers. Commented Feb 5, 2017 at 0:34
• @TheCount Right, fixed that. All come to one answer. Commented Feb 5, 2017 at 0:38
• The alphabet size is 26 (a-z or A-Z, no punctuation or spaces included), not 36. Commented Feb 5, 2017 at 0:38
• @GreyMatters I used "alphabet" here in a computer science sense to mean "number of usable characters", but I've swapped the latter in. Commented Feb 5, 2017 at 0:40
• You and I still have different answers. Commented Feb 5, 2017 at 0:41

First, there are the following possibilities for strings:

• 32-character strings containing only small letters
• 32-character strings containing only capital letters
• 32-character strings containing only digits
• 32-character strings containing only small letters and capital letters
• 32-character strings containing only small letters and digits
• 32-character strings containing only capital letters and digits
• 32-character strings containing small letters, capital letters and digits

So, by removing the first 3 categories, what you'll end up with is the total number of 32-character strings which combine 2 or more of the categories. Make sure that's the answer you want.

26 small letters + 26 capital letters + 10 digits = 62 characters total. For the first character in a string, you obviously have 62 possibilities. Since the next character can be the same or different, you have 62 possibilities there as well, or $62^{2}$ possibilities for 2 characters. Adding a 3rd character gives $62^{3}$ possibilities. For 32 characters, then, there's $62^{32}$ possibilities.

There are 26 possible small letters, so by the same logic, you'll get $26^{32}$ possibilities for 32 character strings containing all small letters.

The same logic and math applies to capital letter-only strings, so there's another $26^{32}$ possibilities.

For 10 different digits, 0 through 9, this works out to $10^{32}$ possibilities.

The equation you want, therefore, is:

$$62^{32}-26^{32}-26^{32}-10^{32}$$

You can get the final total on, say, Wolfram|Alpha.

Again, what you're getting is the number of possible 32-character strings containing combinations of 2 or more of the "small letter", "capital letter" and "digit" categories. It's not only important to get the total, but to understand the meaning of the result, as well.

• I got the impression the OP just wanted to exclude strings of only capitals, only lowercase, and only numbers. Commented Feb 5, 2017 at 0:36
• Nice! We agree! I always love having multiple explanations. +1 Commented Feb 5, 2017 at 0:42
• All the answers posted at this point match, so we're all reading the question in the same way. Now the real question is whether this is actually the answer Virat Choudhary needs? Commented Feb 5, 2017 at 0:46
• It is. Now this problem is no longer complicated to me except the number of digits in the answer haha. Commented Feb 5, 2017 at 0:52