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

5 lines
152 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def comb(m, s):
if m == 1: return [[x] for x in s]
if m == len(s): return [s]
return [s[:1] + a for a in comb(m-1, s[1:])] + comb(m, s[1:])