3
$\begingroup$

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.

$\endgroup$
7
  • $\begingroup$ Do you mean #(strings with at least one of the three types of characters)? $\endgroup$ – Parcly Taxel Feb 5 '17 at 0:16
  • $\begingroup$ YES. Apology if I made the problem sound more complicated. $\endgroup$ – Virat Feb 5 '17 at 0:17
  • 1
    $\begingroup$ Example of strings are : yXgZxJsaRG8o7EBMCXknL6XFW7V9Smmg , x8k9Ifp9ejbEYzyt2TPdkZfY1T5fZNJm , C958NV3IN3m18jVBgrtBkWdSigaDVZao $\endgroup$ – Virat Feb 5 '17 at 0:18
  • 1
    $\begingroup$ This is a nice question. What sorts of approaches have you considered? $\endgroup$ – The Count Feb 5 '17 at 0:19
  • 1
    $\begingroup$ @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. $\endgroup$ – Virat Feb 5 '17 at 0:27
14
$\begingroup$

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$.

$\endgroup$
2
  • 6
    $\begingroup$ Well counted. $\endgroup$ – Carsten S Feb 5 '17 at 3:03
  • 6
    $\begingroup$ @CarstenS Ah! Ah! Ah! $\endgroup$ – The Count Feb 5 '17 at 4:40
7
$\begingroup$

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}$$

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

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.

$\endgroup$
4
  • $\begingroup$ I got the impression the OP just wanted to exclude strings of only capitals, only lowercase, and only numbers. $\endgroup$ – The Count Feb 5 '17 at 0:36
  • $\begingroup$ Nice! We agree! I always love having multiple explanations. +1 $\endgroup$ – The Count Feb 5 '17 at 0:42
  • 2
    $\begingroup$ 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? $\endgroup$ – Grey Matters Feb 5 '17 at 0:46
  • 2
    $\begingroup$ It is. Now this problem is no longer complicated to me except the number of digits in the answer haha. $\endgroup$ – Virat Feb 5 '17 at 0:52

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.