aboutsummaryrefslogtreecommitdiff
path: root/challenge-260/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-03-11 11:24:14 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-03-11 11:24:14 +0000
commit77245595e193396bdb9347f5b5de7a088aea8bae (patch)
tree1e0b98bc1c373281c250c8ea8e340ab33fcca358 /challenge-260/eric-cheung/python
parentb555f7d86b4cc0f38c935a7284549fa0feae24a7 (diff)
downloadperlweeklychallenge-club-77245595e193396bdb9347f5b5de7a088aea8bae.tar.gz
perlweeklychallenge-club-77245595e193396bdb9347f5b5de7a088aea8bae.tar.bz2
perlweeklychallenge-club-77245595e193396bdb9347f5b5de7a088aea8bae.zip
- Added solutions by Eric Cheung.
- Added solutions by Mark Anderson. - Added solutions by W. Luis Mochan. - Added solutions by E.Choroba.
Diffstat (limited to 'challenge-260/eric-cheung/python')
-rwxr-xr-xchallenge-260/eric-cheung/python/ch-1.py10
-rwxr-xr-xchallenge-260/eric-cheung/python/ch-2.py12
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-260/eric-cheung/python/ch-1.py b/challenge-260/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..d324e8781a
--- /dev/null
+++ b/challenge-260/eric-cheung/python/ch-1.py
@@ -0,0 +1,10 @@
+
+## arrInt = [1, 2, 2, 1, 1, 3] ## Example 1
+## arrInt = [1, 2, 3] ## Example 2
+arrInt = [-2, 0, 1, -2, 1, 1, 0, 1, -2, 9] ## Example 3
+
+arrCount = [arrInt.count(elemLoop) for elemLoop in set(arrInt)]
+
+## print (arrCount)
+
+print (1 if len(arrCount) == len(set(arrCount)) else 0)
diff --git a/challenge-260/eric-cheung/python/ch-2.py b/challenge-260/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..17f5aa4003
--- /dev/null
+++ b/challenge-260/eric-cheung/python/ch-2.py
@@ -0,0 +1,12 @@
+
+from itertools import permutations
+
+strWord = "CAT" ## Example 1
+## strWord = "GOOGLE" ## Example 2
+## strWord = "SECRET" ## Example 3
+
+arrPermList = permutations(list(strWord))
+
+arrPermStrList = sorted(list(set(["".join(arrLoop) for arrLoop in list(arrPermList)])))
+
+print (arrPermStrList.index(strWord) + 1)