From c5d362da9678bf0e410da99f957c6ad8e72e56bd Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 12 Dec 2023 15:49:30 +0000 Subject: - Added solutions by Mark Anderson. - Added solutions by Thomas Kohler. - Added solutions by Roger Bell_West. - Added solutions by Niels van Dijke. - Added solutions by Peter Campbell Smith. - Added solutions by Peter Meszaros. - Added solutions by David Ferrone. - Added solutions by W. Luis Mochan. - Added solutions by PokGoPun. - Added solutions by Laurent Rosenfeld. - Added solutions by Eric Cheung. - Added solutions by Ulrich Rieke. --- challenge-247/eric-cheung/python/ch-2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 challenge-247/eric-cheung/python/ch-2.py (limited to 'challenge-247/eric-cheung/python/ch-2.py') 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]) -- cgit