To get the distinct permutations of a set in Python, we can use the permutations()
function from the itertools
module. We can then convert the resulting iterator of tuples to a set to remove duplicates. Here's an example:
main.py109 chars7 lines
Output:
main.py103 chars2 lines
Note that the permutations()
function returns tuples instead of sets, which is why we convert it to a set to remove duplicates.
gistlibby LogSnag