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

7 lines
160 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04: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))