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

5 lines
149 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def comb(m, lst):
if m == 0: return [[]]
return [[x] + suffix for i, x in enumerate(lst)
for suffix in comb(m - 1, lst[i + 1:])]