A small but efficient recursive function for printing the permutation of characters in a given string.
Python, 18 lines
Done initially as a programming excercise this script uses stacks to build the permutations of the characters in the specified string. This does not check for duplicate characters in the specified string but could be modified easily to do so too. Even though the algorithm above uses text/strings as an example, this can easily be used to work with lists of any sort.
I also plan to submit one that does combinations.