solve permutations