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

7 lines
160 B
Python

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))