I am writing a program in Python, and I realized that a problem I need to solve requires me, given a set S
with n
elements (|S|=n), to test a function on all possible subsets of a certain order m
(i.e. with m number of elements). To use the answer to produce a partial solution, and then try again with the next order m=m+1, until m=n.
I am on my way to write a solution of the form:
def findsubsets(S, m):
subsets = set([])
...
return subsets
But knowing Python I expected a solution to be already there.
What is the best way to accomplish this?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…