Let's say I have string, s='AADD'
. I have used more_itertools
and distinct permutation, which would print out (AADD,ADDA,DDAA,ADAD,DADA,DAAD)
.
My question is, because AADD
and DDAA
, ADAD
and DADA
are essentially mirror image of each other, I want to get rid of one of them, how should I revise my code to achieve this?
import more_itertools
s = 'AADD'
#counting = 0
for i in more_itertools.distinct_permutations(s):
print(''.join(i))
#counting += 1
Update: I have another question regards to large amount of data processing. Let's say my string "s" has 50 letters instead of 4, I wonder if the "distinct_permutation" from "more_itertools" is the most efficient way of doing it? I used Mathematica to calculate all the possible combinations, there are more than 10 billons possible combos, I wonder if there's a faster way of accomplishing this task. Apologizing in advance if this question is stupid, because I haven't taken any coding class and am learning coding myself at the same time while doing the project.
You can utilize
reversed()
here:Output: