📜  SymPy | Python中的 Subset.iterate_binary()

📅  最后修改于: 2022-05-13 01:55:09.993000             🧑  作者: Mango

SymPy | Python中的 Subset.iterate_binary()

Subset.iterate_binary() : iterate_binary()是一个 sympy Python库函数,它以 k 步迭代二进制子集。 “k”的值可以是正数或负数。

代码 #1:iterate_binary() 示例

# Python code explaining
# SymPy.Subset.iterate_binary()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.iterate_binary()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# iterate_binary value
print ("Subset a iterate_binary : ", a.iterate_binary(1).subset)

输出 :

代码 #2:iterate_binary() 示例

# Python code explaining
# SymPy.Subset.iterate_binary()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.iterate_binary()
  
# Creating Subset
a = Subset(['c', 'd'], ['23', 'c', 'd'])
  
# iterate_binary value
print ("Subset a iterate_binary : ", a.iterate_binary(2).subset)

输出 :