# New but efficient way to...

• 11-01-2005
jmd15
New but efficient way to...
Hi, I'm just looking for new things to learn(which equals something to do), so what is an unusual or complicated, BUT EFFICIENT, way to list all the possibilities of a string. For example, I have a string, and want to list all the different combinations that the letters in the string could have, so in a sense, scramble the word and list all the different ways the word could be scrambled? Is there many different ways to do it? What way would you do it? Thanks.
• 11-01-2005
durban
think smaller to find your answer. How many different combinations of a base 10 decimal system can 2 digits have? Even lower? think in binary. You should come across your algorithm sooner or later.
• 11-01-2005
jmd15
Yeah, thanks for the reply, but I'm looking for new ways/unusual ways to do this same task.
• 11-01-2005
Daved
Well, I'm not sure this is what you are looking for, but see if you can get code to work using next_permutation from <algorithm>. That is how I would do it (the code is already available, tested, debugged and optimized).

Also consider looking at the code of how your STL implements that method, to see if you can decipher it. That might be its own challenge.

Using existing functions is probably not what you meant by unusual, but for many C++ programmers actually using the STL might be considered unusual.
• 11-01-2005
jmd15
Yes Daved, that is exactly the kind of thing I was looking for. That is a way I have never heard of and looks interesting, thank you. Any other methods are also welcome.
• 11-01-2005
jmd15
Hey, since that pretty much died, how about anybody posting any way they would do it. No matter if that way is commonly used or very bizarre. It would be fun to try out and see how many different ways there are to do one thing.