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.
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.
Re: How many words are possible with the english alphabet.
Quote:
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?
Re: How many words are possible with the english alphabet.
yep, it'll be 10 in base 26 :-P
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.
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
Re: How many words are possible with the english alphabet.
Quote:
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.
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...... ! @ # $ % ^ & * ( ) ' ; . , and such..
That quickly became unreasonable so i went with all possible words for fun.
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.