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

from typing import List


def generate_numbers(numbers: List[int], x: int, y: int, current: str) -> List[int]:
    if x == 0:
        return [int(current)] if int(current) < y else []
    result = []
    for num in numbers:
        result.extend(generate_numbers(numbers, x - 1, y, current + str(num)))
    return result

if __name__ == "__main__":
    L = [0, 1, 2, 5]
    X = 2
    Y = 21

    output = generate_numbers(L, X, Y, "")
    print(", ".join(map(str, output)))