Implemented from a posting on SO:
http://stackoverflow.com/questions/4240080/generating-all-permutations-of-a-given-string