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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with Anagram problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Please help
I need an anagram routine. I do not want it to use a dictionary etc. It should just take a word, and generate all possible combinations of letters. For example, if it was passed ABC, it would return ABC, ACB, BAC, BCA, CAB and CBA. COde must be simple as well please.


Thanks,
Geoff.
 
To do the anagram, you need to keep in mind that this is a problem in factorials, so you will have to do a count on the input string so you will know how to set up the factorial, otherwise you will get redundant answers.
Input string
Store input in a variable (if needed)
Count string length
String length (factorial)
Setup a loop to generate unique combinations based on the factorial size.
You can store all of your potential answers into an array or the answers could be output as they are generated if that is all you want.
hope this helps a bit.
houdinihar
 
Thanks but I'm confused. COuld you provide some sort of example please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top