i wanted to tell you about the internals of the
c++ next_permutation algorithm because it does some things which the recursive algorithm will not. it recognizes that "aaa" has only identical permutations. i found
this article which explains permutations pretty well. i thought you might find it interesting as well.