We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84a41ea commit 61c0743Copy full SHA for 61c0743
domdf_python_tools/utils.py
@@ -154,3 +154,21 @@ def splitLen(string,n):
154
155
return [string[i:i+n] for i in range(0,len(string),n)]
156
157
+
158
+def permutations(data, n=2):
159
+ """
160
+ Return permutations containing `n` items from `data` without any reverse duplicates
161
162
+ :type data: list or string
163
+ :type n: int
164
165
+ :rtype: list of tuples
166
167
168
+ import itertools
169
+ perms = []
170
+ for i in itertools.permutations(data, n):
171
+ """from https://stackoverflow.com/questions/10201977/how-to-reverse-tuples-in-python"""
172
+ if i[::-1] not in perms:
173
+ perms.append(i)
174
+ return perms
0 commit comments