From 0040b8b93d96c422f23486eef3f731019a289845 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 11 Apr 2023 11:16:20 +0100 Subject: - Added solutions by W. Luis Mochan. - Added solutions by Lubos Kolouch. - Added solutions by Peter Meszaros. - Added solutions by Luca Ferrari. --- challenge-212/eric-cheung/python/ch-1.py | 22 ++++++++++++++++++++++ challenge-212/eric-cheung/python/ch-2.py | 23 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 challenge-212/eric-cheung/python/ch-1.py create mode 100755 challenge-212/eric-cheung/python/ch-2.py (limited to 'challenge-212/eric-cheung/python') diff --git a/challenge-212/eric-cheung/python/ch-1.py b/challenge-212/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..f7a2780aed --- /dev/null +++ b/challenge-212/eric-cheung/python/ch-1.py @@ -0,0 +1,22 @@ + +## Example 1 +## strWordInput = "Perl" +## arrJumpStep = [2, 22, 19, 9] + +## Example 2 +strWordInput = "Raku" +arrJumpStep = [24, 4, 7, 17] + +arrOuputChar = [] + +for nIndx, charLoop in enumerate(strWordInput): + + bIsUpper = charLoop.isupper() + nJumpChar = ord(charLoop) + arrJumpStep[nIndx] + + if nJumpChar > ord("Z" if bIsUpper else "z"): + nJumpChar = nJumpChar % ord("Z" if bIsUpper else "z") + ord("A" if bIsUpper else "a") - 1 + + arrOuputChar.append(chr(nJumpChar)) + +print ("".join(arrOuputChar)) diff --git a/challenge-212/eric-cheung/python/ch-2.py b/challenge-212/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..8514d9b415 --- /dev/null +++ b/challenge-212/eric-cheung/python/ch-2.py @@ -0,0 +1,23 @@ + +## Example 1: +## arrList = [1, 2, 3, 5, 1, 2, 7, 6, 3] +## nSizeSplit = 3 + +## Example 2: +## arrList = [1, 2, 3] +## nSizeSplit = 2 + +## Example 3: +## arrList = [1, 2, 4, 3, 5, 3] +## nSizeSplit = 3 + +## Example 4: +arrList = [1, 5, 2, 6, 4, 7] +nSizeSplit = 3 + +if len(arrList) % nSizeSplit == 0: + arrList.sort() + for nIndx in range(0, len(arrList), nSizeSplit): + print (arrList[nIndx:nIndx + nSizeSplit]) +else: + print (-1) -- cgit