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

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

  1. #16
    Join Date
    Feb 2009
    Location
    USA
    Posts
    68

    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. #17
    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. #18
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,725

    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

  4. #19
    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. #20
    Join Date
    Feb 2009
    Location
    USA
    Posts
    68

    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. #21
    Join Date
    Feb 2009
    Location
    USA
    Posts
    68

    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. #22
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,347

    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.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  8. #23
    Join Date
    Feb 2009
    Location
    USA
    Posts
    68

    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 01:33 PM.

  9. #24
    Join Date
    Feb 2009
    Location
    USA
    Posts
    68

    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.

Page 2 of 2 FirstFirst 12

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center