Solve string permutations