Posted on 1997-10-30
Where can I find the source code for an Anagram algorithm that will take an input string of any length - eg. "abc" and return a list of all the possible permutations? The number of solutions should be N! (n * (n-1) * (n-2) * ... * 1); eg.
"abc", "bac", "bca", "cba", "cab", "acb"
I think I'm about 80-90% there, using loops to rotate the string, then substrings on successively smaller subsets. The above sample output would be generated by first rotating the full string (len 3), then a smaller subset (len 2). This may not give exactly the same # of solutions as expected when you get to 4 or more characters.