solution to CommonPermutations problem