aboutsummaryrefslogtreecommitdiff
path: root/challenge-051/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2024-09-16 09:41:35 +0200
committerLubos Kolouch <lubos@kolouch.net>2024-09-16 09:41:35 +0200
commit65b9d6b25e0a823ca7ab6d15744ff98eb3697471 (patch)
treefcbcdebd50e3e146dfecf519701ec04b191053eb /challenge-051/paulo-custodio/python/ch-2.py
parentbd1fe7ae50ca42bda58c134b9edfdc287fb3f386 (diff)
parent68e321dd32a834f54b55d5e8924f04358e41cf1f (diff)
downloadperlweeklychallenge-club-65b9d6b25e0a823ca7ab6d15744ff98eb3697471.tar.gz
perlweeklychallenge-club-65b9d6b25e0a823ca7ab6d15744ff98eb3697471.tar.bz2
perlweeklychallenge-club-65b9d6b25e0a823ca7ab6d15744ff98eb3697471.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-051/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-051/paulo-custodio/python/ch-2.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-051/paulo-custodio/python/ch-2.py b/challenge-051/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..5a120fe9de
--- /dev/null
+++ b/challenge-051/paulo-custodio/python/ch-2.py
@@ -0,0 +1,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()]))