aboutsummaryrefslogtreecommitdiff
path: root/challenge-260/eric-cheung/python
diff options
context:
space:
mode:
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)