1. ## Word Scramble

Does anyone know an algorithm to find all possible combinations of letters of a word

2. If you find out the word lenght and put the word in an ARRAY, its probably gonna be very easy to do that

3. Do you mean if you had "ABOFGHIEQ", find all the possible words?

- or -

Do you mean if you had "BMJ lives in Chicago", find all the different possible letter combinations?

Does anyone know an algorithm to find all possible combinations of letters of a word

5. Hey, I'm just making sure... people on this board have a habit of poorly phrasing questions; sheesh

6. I've also noticed quite a few people who are very snotty to others. It's not necessary.

Brendan

7. >Does anyone know an algorithm to find all possible combinations of letters of a word
Yes, but the real question is do you want to find the number of combinations or actually print each combination? If all you are doing is finding N and printing that then the solution is simply finding the factorial of the number of letters in the word:
Code:
```long perm ( int len )
{
int N = 1;
for ( ; len > 1; len-- )
N *= len;
return N;
}```
Actually printing each combination is more difficult because you have to take a string and rotate the characters accordingly for each combination.

-Prelude

8. I actually need to print all the combinations on the screen

9. ## Reiterate

I think I might need to clarify my dilemma. I need to print into a file using fstream a list of all the possible combinations of a word. The word can be anylength and combinations don't need to be words.

For example:

if the user inputs "that" the following list would be produced, but unlike this list it shouldn't have repititions.

that
thta
taht
tath
ttha
ttah
htat
htta
hatt
hatt
htat
htta
atth
atht
ahtt
ahtt
atth
atht
ttah
ttha
that
thta
taht
tath

10. >I think I might need to clarify my dilemma.
There's no need for clarification. Here is what I meant by rotate the letters in the word:
Code:
```#include <iostream>
#include <string>

// No error checking is done, beware.

void rotate ( std::string &s, int len )
{
int i, pos = s.length() - len;
char temp = s[pos];
for ( i = pos + 1; i < s.length(); i++ )
s[i - 1] = s[i];
s[i - 1] = temp;
}

void perm ( std::string &s, int len )
{
if ( len != 1 ) {
for ( int i = 0; i < len; i++ ) {
perm ( s, len - 1 );
if ( len == 2 )
std::cout<< s <<std::endl;
rotate ( s, len );
}
}
}

int main()
{
std::string word;
std::cout<<"Enter a word: "<<std::flush;
std::getline ( std::cin, word );
perm ( word, word.length() );
return 0;
}```
Feel free to use that as a template, but be sure you understand what it is doing, that is have the fun. Now, since I'm sure if I do not tell you this you will come back saying that it doesn't do what you wanted...Of course it doesn't, this prints all combinations. If you want to remove duplicates then you need to save each combination in some kind of list and check each new combination to see if it is already there. This is a project for you, I refuse to write all of your homework.

Good luck!

-Prelude

11. my friend forgot to note that the code may not contain arrays
thanks,
sm

12. y the way our whole class is stumped since all but one person did much programming durring the summer
(summer jobs)
so pretty much all of our class is having trouble creating loops
i thank you for any info you can give that might be of any use
- sm

13. >the code may not contain arrays
My first response to this was "Bwahahaha". This is the second most ridiculous restriction I have heard, the first being to write non-trivial programs in Scheme without using assignments. Yes, it is as hard as it sounds. Could you be specific as to what your exact requirements are so that I can be in a better position to answer accurately?

-Prelude

14. since we have not formally learned arrays we are not allowed to use them in our programs with few exceptions

15. If you can't use arrays, use pointer notation. Wherever you have:

array[x]

Replace it with:

*(array+x)

See how much fun that is?

Quzah.