diff options
Diffstat (limited to 'challenge-212/eric-cheung/python')
| -rwxr-xr-x | challenge-212/eric-cheung/python/ch-1.py | 22 | ||||
| -rwxr-xr-x | challenge-212/eric-cheung/python/ch-2.py | 23 |
2 files changed, 45 insertions, 0 deletions
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)
|
