RosettaCodeData/Task/Combinations/Python/combinations-4.py

7 lines
160 B
Python
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
def comb(m, s):
if m == 0: return [[]]
if s == []: return []
return [s[:1] + a for a in comb(m-1, s[1:])] + comb(m, s[1:])
print comb(3, range(5))