Word Generator

Ok I'm trying to make a srable word generator but I really don't have a clue on how to start it out.
If anyone would be willing to help me out with a basic program that does this and with some ideas on how to make it faster
Eg if its done with recursion it'd probably be pretty slow

Thanks in adv!
LVL 2
MasterThaiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tobydavidCommented:
Did you mean "Scrabble"?  so that you are looking for all possible words using all 7 letters, all words using any 6 out of the 7 letters, any 5 of the 7, etc.?
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Hi MasterThai,

What programming language are you working in here?

I once developed a fast routine in VB.Net using a DAWG:
http://www.wutka.com/dawg.html

First I found a word list I was happy with:
http://www.google.com/search?complete=1&hl=en&q=word+list

Then I built a DAWG structure from the word list.  I didn't do any kind of optimization with it.  I just basically built a nested HashTable system.  The root HashTable had each letter of the alphabet and represented words that begin with that letter.  Then each letter had a HashTable associated with it that represented the second letter in a possible word and so on...

When you start making permutations of all possible tile combinations you can quickly eliminate an entire series of permutations by using the DAWG structure to determine if there are no possible words that can made with that combinations current prefix.

For example, what if your tiles included a "q" and a "z"?  Let's say your tile combination generator is current building permutations that start with "zq"?????.  If the DAWG says that there are no words that begin with "zq" then you can stop making permutations with that series and move on to the next letter.  This is what makes it fast.  This can be determined quickly becuase the HashTable associated with the first letter "z" would not have an entry for "q" indicating that no words begin with "zq".

If you simply made all permutations of the tiles and checked to see if any of those permutations match any WHOLE words in your list, then you may make literally thousands of combinations that could have been avoided altogether with the DAWG approach.

~IM
MasterThaiAuthor Commented:
Sorry thought I posted C/C++ I Don't have .Net
So I'm using Dev Cpp
and yeah im trying to make a scrabble word finder
basically I'm looking for something like this right now

Scrabble Word Generator...
Step 1 Get Letters...
Search 7 digit words that have each letter in it
Search 6 ...
Search 5 ...

Take Top 20 (Point Valued Words)
Put in a Text File
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

ozoCommented:
Do you have a dictionary of valid Scrabble words to work from?
Do you have any letters on the board to work around, or double or triple letter of word squares to take into acount?
MysticalNeopianCommented:
I'm not trying to make something to play the game I'm just trying to make a program that searches a txt file and finds all the words possible based off the given letters.

ozoCommented:
#include <ctype.h>
#include <stdio.h>
int value[]={ /* assuming english version */
  1,/*A*/
  3,/*B*/
  3,/*C*/
  2,/*D*/
  1,/*E*/
  4,/*F*/
  2,/*G*/
  4,/*H*/
  1,/*I*/
  8,/*J*/
  5,/*K*/
  1,/*L*/
  3,/*M*/
  1,/*N*/
  1,/*O*/
  3,/*P*/
  10,/*Q*/
  1,/*R*/
  1,/*S*/
  1,/*T*/
  1,/*U*/
  4,/*V*/
  4,/*W*/
  8,/*X*/
  4,/*Y*/
  10,/*Z*/  
};
main(){
  char word[99];
  struct{
    int points;
    char word[9];
  }top20[21];  
  FILE *f=fopen("wordlist","r");
  char *p;
  int i;
  if( !f ){
    perror("worklist");
    exit(1);
  }
  for( i=0;i<20;i++ ){ top20[i].points=0; top20[i].word[0]='\0'; }
  while( p=fgets(word,99,f) ){
    int points=0;
    if( strlen(word)>8 ){ continue; }
    while( isalpha(*p) ){
      points+=value[toupper(*p++)-'A'];
    }
    for( i=19;i>=0 && points > top20[i].points;i-- ){
      top20[i+1] = top20[i];
    }
    if( i<19 ){
      top20[i+1].points=points;
      strcpy(top20[i+1].word,word);
    }
  }
  for( i=0;i<20;i++ ){
    printf("%2d: %s",top20[i].points,top20[i].word);
  }
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.