当列表中有重复的排名时,如何有效地从列表中获取所有有效的重新排名排列?

How to efficiently get all the valid re-ranked permutations from a list when it has duplicate ranks inside it?

提问人:Deshwal 提问时间:11/2/2023 最后编辑:Deshwal 更新时间:11/2/2023 访问量:51

问:

假设两个人得到了相似的分数或分数。从理论上讲,您可以为它们分配相同的等级,但是如果存在不能有重复等级的约束怎么办?

例子:

  • 输入:[1,1,2]可以写成输出:[1,2,3],[2,1,3]
  • 输入:[1,1,1],可以写成任何排列,因为任何位置都可以有任何可能的排名输出:[1,2,3],[1,3,2],[2,2,3]....[3,2,1]
  • 输入:[2,1,2]可以写成输出:[2,1,3],[3,1,2]
  • 输入:[1,2,3] 没有其他排列,因此输出 = 无
  • 输入:[1,2,2] 可以是 输出:[1,2,3], [1,3,2]

还有另一种解决方案,但它给出了我不能的重复排名

到目前为止,我已经想出了这个代码,它从现有列表中生成了采样池

from collections import Counter
from itertools import permutations
import random 


ranks = [1,2,2,3,3,1,1,2,4,2]
counter = Counter(ranks)
sorted_counter = dict(sorted(counter.items(), key = lambda x: x[0]))
print(sorted_counter)


range_to_from = {1:(1,counter[1])}
sample_from = {}# wherever you find any rank "i", you can replace it with any number from the range

for key,val in sorted_counter.items():
    if key == 1:
        sample_from[1] = list(range(val+1))
        continue
    else:
        start, end = (range_to_from[key-1][-1]+1, range_to_from[key-1][-1]+val)
        range_to_from[key] = (start,end)
        sample_from[key] = list(range(start,end+1))

如果你在 a 中执行以下操作,你会得到所有可能的值,但它';;比较每个生成的列表的成本太高了:while i != all_possible_perms

# Get single permutation from the list
new_ranks = []
for item in ranks:
    sub = random.choice(sample_from[item])
    sample_from[item].remove(sub)
    new_ranks.append(sub)

new_ranks
python-3.x 算法 排列 排名

评论

4赞 DjaouadNM 11/2/2023
问题到底是什么?输入/输出示例是什么?
1赞 Deshwal 11/2/2023
@DjaouadNM我已经用逻辑将示例输入和输出以列表方式放置,但同样,为了方便起见,我再次命名了它们。谢谢你提醒我平台的指导方针。

答:

1赞 Kelly Bundy 11/2/2023 #1

对于输入,我首先找到等值索引组:、 和 。我得到每个排列并构建产品,所以例如我有.然后我把它们链接起来,从左到右分配等级。[1,2,2,3,3,1,1,2,4,2][0, 5, 6][1, 2, 7, 9][3, 4][8]x = ((6,0,5), (2,9,7,1), (3,4), (8,))

from itertools import chain, count, groupby, permutations, product

ranks = [1,2,2,3,3,1,1,2,4,2]

key = ranks.__getitem__
groups = (g for k, g in groupby(sorted(range(len(ranks)), key=key), key))
for x in product(*map(permutations, groups)):
    for i, ranks[i] in zip(chain(*x), count(1)):
        pass
    print(ranks)

输出(在线尝试!

[1, 4, 5, 8, 9, 2, 3, 6, 10, 7]
[1, 4, 5, 9, 8, 2, 3, 6, 10, 7]
[1, 4, 5, 8, 9, 2, 3, 7, 10, 6]
[1, 4, 5, 9, 8, 2, 3, 7, 10, 6]
[1, 4, 6, 8, 9, 2, 3, 5, 10, 7]
[1, 4, 6, 9, 8, 2, 3, 5, 10, 7]
[1, 4, 7, 8, 9, 2, 3, 5, 10, 6]
[1, 4, 7, 9, 8, 2, 3, 5, 10, 6]
[1, 4, 6, 8, 9, 2, 3, 7, 10, 5]
[1, 4, 6, 9, 8, 2, 3, 7, 10, 5]
[1, 4, 7, 8, 9, 2, 3, 6, 10, 5]
[1, 4, 7, 9, 8, 2, 3, 6, 10, 5]
[1, 5, 4, 8, 9, 2, 3, 6, 10, 7]
[1, 5, 4, 9, 8, 2, 3, 6, 10, 7]
[1, 5, 4, 8, 9, 2, 3, 7, 10, 6]
[1, 5, 4, 9, 8, 2, 3, 7, 10, 6]
[1, 6, 4, 8, 9, 2, 3, 5, 10, 7]
[1, 6, 4, 9, 8, 2, 3, 5, 10, 7]
[1, 7, 4, 8, 9, 2, 3, 5, 10, 6]
[1, 7, 4, 9, 8, 2, 3, 5, 10, 6]
[1, 6, 4, 8, 9, 2, 3, 7, 10, 5]
[1, 6, 4, 9, 8, 2, 3, 7, 10, 5]
[1, 7, 4, 8, 9, 2, 3, 6, 10, 5]
[1, 7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