Derecursion of string permutations (+ unit test).