def subsets(elements, size):
""" Generates all subsets of the given size of the given set.
"""
if size > 0:
while len(elements) > 0:
first = elements.pop()
for the_rest in subsets(elements.copy(), size-1):
yield (first,)+the_rest
else:
yield ()
The colors are a tad funky, given my choice of background, but it works!
Instructions are here.

1 comments:
What chapter are you on TECS
Post a Comment