aboutsummaryrefslogtreecommitdiff
path: root/challenge-051/lubos-kolouch/python/ch-2.py
blob: 56605c1568cfeaf79e41223596be40c287b33a98 (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 -*-

def is_colorful(number: int) -> bool:
    products = set()

    digits = [int(d) for d in str(number)]
    length = len(digits)

    for i in range(length):
        product = 1
        for j in range(i, length):
            product *= digits[j]
            if product in products:
                return False
            products.add(product)

    return True

if __name__ == "__main__":
    for num in range(100, 1000):
        if is_colorful(num):
            print(num)