code_junkie

How can I find all the subsets of a set, with exactly n elements?

Nov 13th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.16 KB | None | 0 0
  1. def findsubsets(S,m):
  2. subsets=set([])
  3. ...
  4. return subsets
  5.  
  6. import itertools
  7. def findsubsets(S,m):
  8. return set(itertools.combinations(S, m))
Add Comment
Please, Sign In to add comment