I want to create all the possible combinations of a tuple with duplicate elements.
For example lets say that we have {3,3,0}. I want the code to return: (3,3,0) (3,0,3) (0,3,3)
I looked at itertools documentation and at numerous stack overflow questions but i did not find a answer to this.
How can I implement it? Or, can this be implemented in general?
You could use permutations
from itertools and then use a set
to remove any doubles:
result = set(permutations((3, 3, 0)))