aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-29 10:40:34 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-11-29 10:40:34 +0000
commit26d3aa51bc50bdd800d2a4b9556120d94a5f99af (patch)
tree82c252b624e0cdd442523c209305562e88d62290
parentfd347afa693f7e4a43777528f50c9b0a80c32cdc (diff)
downloadperlweeklychallenge-club-26d3aa51bc50bdd800d2a4b9556120d94a5f99af.tar.gz
perlweeklychallenge-club-26d3aa51bc50bdd800d2a4b9556120d94a5f99af.tar.bz2
perlweeklychallenge-club-26d3aa51bc50bdd800d2a4b9556120d94a5f99af.zip
- Added guest contributions by Eric Cheung.
-rwxr-xr-xchallenge-193/eric-cheung/python/ch-1.py12
-rwxr-xr-xchallenge-193/eric-cheung/python/ch-2.py19
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-193/eric-cheung/python/ch-1.py b/challenge-193/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..5b4ca78f08
--- /dev/null
+++ b/challenge-193/eric-cheung/python/ch-1.py
@@ -0,0 +1,12 @@
+
+from itertools import product
+
+## nInput = 2 ## Example 1
+nInput = 3 ## Example 2
+
+arrStrOutput = []
+
+for arrIndx in product(range(2), repeat = nInput):
+ arrStrOutput.append("".join([str(nIndx) for nIndx in arrIndx]))
+
+print (arrStrOutput)
diff --git a/challenge-193/eric-cheung/python/ch-2.py b/challenge-193/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..a28f7f0aac
--- /dev/null
+++ b/challenge-193/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+def GetDiffStr(strInput):
+ return ",".join([str(ord(strInput[nIndx]) - ord(strInput[nIndx - 1])) for nIndx in range(1, len(strInput))])
+
+## arrInputStr = ["adc", "wzy", "abc"] ## Example 1
+arrInputStr = ["aaa", "bob", "ccc", "ddd"] ## Example 2
+
+arrStrAppend = []
+strOdd = ""
+
+for strLoop in arrInputStr:
+ arrStrAppend.append(GetDiffStr(strLoop))
+
+for nIndxLoop, strLoop in enumerate(arrStrAppend):
+ if arrStrAppend.count(strLoop) == 1:
+ strOdd = arrInputStr[nIndxLoop]
+ break
+
+print (strOdd)