我正在试验sympyapi的组合。你知道吗
首先,没有替换的组合。。。你知道吗
from sympy.functions.combinatorial.numbers import nC
from sympy.utilities.iterables import combinations
nC('abc', 2)
# >>> 3
list(combinations('abc', 2))
# >>> [('a', 'b'), ('a', 'c'), ('b', 'c')]
我现在想列出组合替换
nC('abc', 2, replacement=True)
# >>> 6
但是,combinations()方法似乎不支持“replacements”参数?你知道吗
Init signature: combinations(self, /, *args, **kwargs)
Docstring:
combinations(iterable, r) --> combinations object
Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
Type: type
这是另一种方法
相关问题 更多 >
编程相关推荐