aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/eric-cheung/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-255/eric-cheung/python')
-rwxr-xr-xchallenge-255/eric-cheung/python/ch-1.py29
-rwxr-xr-xchallenge-255/eric-cheung/python/ch-2.py19
2 files changed, 48 insertions, 0 deletions
diff --git a/challenge-255/eric-cheung/python/ch-1.py b/challenge-255/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..fdd8032691
--- /dev/null
+++ b/challenge-255/eric-cheung/python/ch-1.py
@@ -0,0 +1,29 @@
+
+import sys
+
+## Example 1
+## strInput = "Perl"
+## strCheck = "Preel"
+
+## Example 2
+## strInput = "Weekly"
+## strCheck = "Weeakly"
+
+## Example 3
+strInput = "Box"
+strCheck = "Boxy"
+
+arrUniqCharInput = list(set(strInput))
+arrCharInputCount = [strInput.count(charLoop) for charLoop in arrUniqCharInput]
+
+arrUniqCharCheck = list(set(strCheck))
+arrUniqCheck = [strCheck.count(charLoop) for charLoop in arrUniqCharCheck]
+
+for nIndx, charLoop in enumerate(arrUniqCharCheck):
+ if charLoop not in arrUniqCharInput:
+ print (charLoop)
+ sys.exit()
+
+ if arrUniqCheck[nIndx] > arrCharInputCount[arrUniqCharInput.index(charLoop)]:
+ print (charLoop)
+ sys.exit()
diff --git a/challenge-255/eric-cheung/python/ch-2.py b/challenge-255/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..046fceb06e
--- /dev/null
+++ b/challenge-255/eric-cheung/python/ch-2.py
@@ -0,0 +1,19 @@
+
+import numpy as np
+
+## Example 1
+## strPara = "Joe hit a ball, the hit ball flew far after it was hit."
+## strBan = "hit"
+
+## Example 2
+strPara = "Perl and Raku belong to the same family. Perl is the most popular language in the weekly challenge."
+strBan = "the"
+
+arrWordSet = strPara.replace(strBan, "").replace(",", "").replace(".", "").split()
+arrWordUniqSet = list(set(arrWordSet))
+arrWordCount = [arrWordSet.count(wordLoop) for wordLoop in arrWordUniqSet]
+
+## print (arrWordUniqSet)
+## print (arrWordCount)
+
+print (arrWordUniqSet[np.argmax(arrWordCount)])