aboutsummaryrefslogtreecommitdiff
path: root/challenge-067/lubos-kolouch/python/ch-1.py
blob: d62637d11829d7aecbe0c47f665a6f300922ff17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from typing import List


def combinations(m: int, n: int) -> List[List[int]]:
    result = []

    def rec_comb(start: int, depth: int, comb: List[int]) -> None:
        if depth == 0:
            result.append(comb)
            return
        for i in range(start, m + 1):
            rec_comb(i + 1, depth - 1, comb + [i])

    rec_comb(1, n, [])
    return result


m, n = 5, 2
combinations_list = combinations(m, n)
print("[", ", ".join(str(comb) for comb in combinations_list), "]")