📜  python permutation - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:32.930000             🧑  作者: Mango

代码示例4
def combinations(iterable, r):
    pool = tuple(iterable)
    n = len(pool)
    for indices in permutations(range(n), r):
        if sorted(indices) == list(indices):
            yield tuple(pool[i] for i in indices)