How many words are possible with the english alphabet. - Page 2
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: How many words are possible with the english alphabet.

1. ## Re: How many words are possible with the english alphabet.

Well my original idea was to print all the possiblities to file. Then i started thinking about how long it would take and thats where the "count" concept came up. I think ill write the code for 10 character words and let it run overnite see how far it gets. XD. This was just for fun anyway.

2. Member
Join Date
Mar 2009
Location
Bulgaria
Posts
63

## Re: How many words are possible with the english alphabet.

Code:
```#include <iostream>
#include <vector>

typedef std::vector<char> Container;

const int maxLength = 10;
Container c(maxLength);

void print(int l)
{
for (int i = 0; i < l; ++i)
std::cout << c[i];
std::cout << std::endl;
}

void rec(int i, int l)
{
if (i == l) {
print(l);
return;
}

for (int j = 0; j < 26; ++j) {
c[i] = j + 'A';
rec(i+1, l);
}
}

int main()
{
for (int l = 1; l <= maxLength; ++l) {
c.clear();
rec(0, l);
}

}```
That's not faster, but it's kind of better.

3. ## Re: How many words are possible with the english alphabet.

and thats where the "count" concept came up. I think ill write the code for 10 character words and let it run overnite see how far it gets.
But we already know what the final count should be using our calculators?

4. Senior Member
Join Date
Jan 2009
Posts
1,689

## Re: How many words are possible with the english alphabet.

yep, it'll be 10 in base 26 :-P

5. ## Re: How many words are possible with the english alphabet.

Nice, i love that recursive method and how it changes the characters. Im not too fluent on Vectors and containers in C++, it looks like they are similar to Javas versions but I can see how they are working.

6. ## Re: How many words are possible with the english alphabet.

My calculator cries when i type in.
26^1 + 26^2 + 26^3 + 26^4 + 26^5 + 26^6 + 26^7 + 26^8 + 26^9 +26^10.

I think i said it was something around 10^14

7. Elite Member Power Poster
Join Date
Jan 2006
Location
Singapore
Posts
6,731

## Re: How many words are possible with the english alphabet.

Originally Posted by g.eckert
My calculator cries when i type in.
26^1 + 26^2 + 26^3 + 26^4 + 26^5 + 26^6 + 26^7 + 26^8 + 26^9 +26^10.

I think i said it was something around 10^14
Use a 64 bit integer type, or an arbitrary precision math library like GMP. Actually, the calculator utility that comes with your OS might be able to determine the result without resorting to scientific notation.

8. ## Re: How many words are possible with the english alphabet.

Hmm i had to play around with my Windows calculator but i got it to work.

146,813,779,479,510

146.8 Trillion combinations.. XD

My real original thought was to make a password hacker. Using a file of all possible combinations inluding.

A-Z
a-z
0-9
And all the valid symbols...... ! @ # \$ &#37; ^ & * ( ) ' ; . , and such..

That quickly became unreasonable so i went with all possible words for fun.
Last edited by g.eckert; March 12th, 2009 at 12:33 PM.

9. ## Re: How many words are possible with the english alphabet.

I let the one program run for 10 hours and it only got halfway through 6 character words.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•