-
March 12th, 2009, 10:59 AM
#16
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.
-
March 12th, 2009, 11:08 AM
#17
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.
-
March 12th, 2009, 11:23 AM
#18
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?
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
March 12th, 2009, 11:27 AM
#19
Re: How many words are possible with the english alphabet.
yep, it'll be 10 in base 26 :-P
-
March 12th, 2009, 11:28 AM
#20
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.
-
March 12th, 2009, 11:31 AM
#21
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
-
March 12th, 2009, 12:13 PM
#22
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.
-
March 12th, 2009, 12:26 PM
#23
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.
Last edited by g.eckert; March 12th, 2009 at 12:33 PM.
-
March 13th, 2009, 03:34 AM
#24
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|