Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

permutation of a string/word - good solutions?

Status
Not open for further replies.

gingerfish

Programmer
Jan 20, 2011
5
0
0
CH
Hi,

I have a question of how to tackle following task:

A string/word, e.g. ‘ABC’, needs to be displayed with all its permutations.
So from ‘ABC’ it would get me
‘ABC’, ‘ACB’, ‘BAC’, BCA’, ‘CAB’, CBA’.

What is the best way of doing that?
I was thinking of an array holding four variables, one for counting and three for A B C. But then I’m not quite sure about how the loop needs to be.

Any help is much appreciated.

Thanks a lot,
Gingerfish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top