solution to Permutations