From 5bad8a7e7366e0e8b30d580332a026266f69053e Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Mon, 5 Feb 2024 19:23:23 +0000 Subject: - Added solutions by Eric Cheung. - Added solutions by Laurent Rosenfeld. - Added solutions by Matthew Neleigh. - Added solutions by Mark Anderson. - Added solutions by Luca Ferrari. - Added solutions by PokGoPun. - Added solutions by Robbie Hatley. - Added solutions by Thomas Kohler. - Added solutions by W. Luis Mochan. - Added solutions by Simon Proctor. - Added solutions by Steven Wilson. - Added solutions by David Ferrone. - Added solutions by Peter Meszaros. --- challenge-255/eric-cheung/python/ch-2.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 challenge-255/eric-cheung/python/ch-2.py (limited to 'challenge-255/eric-cheung/python/ch-2.py') 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)]) -- cgit