aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
authorrir <rirans@comcast.net>2024-02-09 21:20:12 -0500
committerrir <rirans@comcast.net>2024-02-09 21:20:12 -0500
commit138a757205ea1278fec6191eecdfa31b9d4fd3cc (patch)
tree08d8157e2f400c51e90e1bc6fcdb34581decb9b9 /challenge-255/eric-cheung/python/ch-2.py
parent844af3cafa518e1f64f5a0729fcc69e1adfcba14 (diff)
parent399287fcd1fa2800c9ab44b9a065116e9a55ec86 (diff)
downloadperlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.tar.gz
perlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.tar.bz2
perlweeklychallenge-club-138a757205ea1278fec6191eecdfa31b9d4fd3cc.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-255/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-255/eric-cheung/python/ch-2.py19
1 files changed, 19 insertions, 0 deletions
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)])