相关疑难解决方法(0)

从具有重叠的池中挑选无序组合

我有值池,我想通过从某些池中挑选来生成所有可能的无序组合.

例如,我想从池0,池0和池1中选择:

>>> pools = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
>>> part = (0, 0, 1)
>>> list(product(*(pools[i] for i in part)))
[(1, 1, 2), (1, 1, 3), (1, 1, 4), (1, 2, 2), (1, 2, 3), (1, 2, 4), (1, 3, 2), (1, 3, 3), (1, 3, 4), (2, 1, 2), (2, 1, 3), (2, 1, 4), (2, 2, 2), (2, 2, 3), (2, 2, 4), (2, 3, 2), (2, 3, 3), (2, 3, 4), …
Run Code Online (Sandbox Code Playgroud)

python combinations combinatorics

25
推荐指数
5
解决办法
794
查看次数

标签 统计

combinations ×1

combinatorics ×1

python ×1