Circular Permutation With Repetition Python