aboutsummaryrefslogtreecommitdiff
path: root/challenge-051/paulo-custodio/python/ch-2.py
blob: 5a120fe9ded364ad08edbe3b8cbccb6743b7d7d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3

# Challenge 051
#
# TASK #2
# Colourful Number
# Write a script to display all Colorful Number with 3 digits.
#
# A number can be declare Colorful Number where all the products of consecutive
# subsets of digit are different.
#
# For example, 263 is a Colorful Number since 2, 6, 3, 2x6, 6x3, 2x6x3 are
# unique.

def uniq(mylist):
    return list(dict.fromkeys(mylist))

def colorful():
    out = []
    for a in range (1, 10):
        for b in range(10):
            for c in range(10):
                prods = [a, b, c, a*b, b*c, a*b*c]
                if len(uniq(prods)) == 6:
                    out.append(a*100+b*10+c)
    return out

print(", ".join([str(x) for x in colorful()]))