aboutsummaryrefslogtreecommitdiff
path: root/challenge-134/paulo-custodio/python
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-10-15 17:50:44 +0100
committerGitHub <noreply@github.com>2021-10-15 17:50:44 +0100
commit5d0c61021788fef304eeafe52fbefda2c6364b11 (patch)
tree3bacb780cb6832627eb3e5af83ca2c2d35a49448 /challenge-134/paulo-custodio/python
parentb20aa9b1c95c89fd1979bb5515f397913d6b1bc7 (diff)
parent3f3955e416d99b640c191c446d3c36acdd1509be (diff)
downloadperlweeklychallenge-club-5d0c61021788fef304eeafe52fbefda2c6364b11.tar.gz
perlweeklychallenge-club-5d0c61021788fef304eeafe52fbefda2c6364b11.tar.bz2
perlweeklychallenge-club-5d0c61021788fef304eeafe52fbefda2c6364b11.zip
Merge pull request #5026 from pauloscustodio/devel
Add Perl and Python solutions to challenge 134
Diffstat (limited to 'challenge-134/paulo-custodio/python')
-rw-r--r--challenge-134/paulo-custodio/python/ch-1.py19
-rw-r--r--challenge-134/paulo-custodio/python/ch-2.py18
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-134/paulo-custodio/python/ch-1.py b/challenge-134/paulo-custodio/python/ch-1.py
new file mode 100644
index 0000000000..814125549b
--- /dev/null
+++ b/challenge-134/paulo-custodio/python/ch-1.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+# TASK #1 > Pandigital Numbers
+# Submitted by: Mohammad S Anwar
+# Write a script to generate first 5 Pandigital Numbers in base 10.
+#
+# As per the wikipedia, it says:
+#
+# A pandigital number is an integer that in a given base has among its
+# significant digits each digit used in the base at least once.
+
+# solution from https://oeis.org/A050278
+
+from itertools import permutations
+
+A050278 = [int(''.join(d)) for d in permutations('0123456789', 10) if d[0] != '0']
+A050278.sort()
+for i in range(0, 5):
+ print(A050278[i])
diff --git a/challenge-134/paulo-custodio/python/ch-2.py b/challenge-134/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..d378a11ca2
--- /dev/null
+++ b/challenge-134/paulo-custodio/python/ch-2.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+# TASK #2 > Distinct Terms Count
+# Submitted by: Mohammad S Anwar
+# You are given 2 positive numbers, $m and $n.
+#
+# Write a script to generate multiplication table and display count of distinct
+# terms.
+
+import sys
+
+m, n = int(sys.argv[1]), int(sys.argv[2])
+terms = set()
+for a in range(1, m+1):
+ for b in range(1, n+1):
+ prod = a * b
+ terms.add(prod)
+print(len(terms))