小编Ish*_*don的帖子

在Python中生成唯一排列

我希望找到列表的独特排列,x = ["$ 5","$ 10","$ 10","TAX","$ 5","20%","BOGO","BOGO","税" "]以9人为一组

我目前正在做的是

from itertools import permutations
x = ["$5", "$10", "$10", "TAX", "$5", "20%", "BOGO", "BOGO", "TAX"]
combos = []
for i in permutations(x, 9):
    if i not in combos:
        combos.append(i)
print combos
Run Code Online (Sandbox Code Playgroud)

然而,这需要太长时间才能运行,我想知道是否有人能给我一个更有效的解决方案.

python

3
推荐指数
1
解决办法
3891
查看次数

标签 统计

python ×1