aboutsummaryrefslogtreecommitdiff
path: root/challenge-247/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-247/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-247/eric-cheung/python/ch-2.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/challenge-247/eric-cheung/python/ch-2.py b/challenge-247/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..61a6df3724
--- /dev/null
+++ b/challenge-247/eric-cheung/python/ch-2.py
@@ -0,0 +1,12 @@
+
+## strInput = "abcdbca" ## Example 1
+strInput = "cdeabeabfcdfabgcd" ## Example 2
+
+arrPairStr = [strInput[nIndxLoop : nIndxLoop + 2] for nIndxLoop in range(len(strInput) - 1)]
+
+arrUniqPair = list(set(arrPairStr))
+arrCountPair = [arrPairStr.count(strLoop) for strLoop in arrUniqPair]
+
+arrMaxPair = sorted([arrUniqPair[nIndx] for nIndx in range(len(arrCountPair)) if arrCountPair[nIndx] == max(arrCountPair)])
+
+print (arrMaxPair[0])