aboutsummaryrefslogtreecommitdiff
path: root/challenge-212/eric-cheung/python
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2023-04-17 16:06:26 +0800
committer冯昶 <fengchang@novel-supertv.com>2023-04-17 16:06:26 +0800
commit64b7c608210e55b5564fe44df68d1eacf6d25969 (patch)
tree685237e70e0a1f8d26440eec4d831853acb2c1c3 /challenge-212/eric-cheung/python
parente2c8b4bec3b682df8597f57ec627508a07582d31 (diff)
parent42228ce601fe37769faacc051f35f74b9566bb26 (diff)
downloadperlweeklychallenge-club-64b7c608210e55b5564fe44df68d1eacf6d25969.tar.gz
perlweeklychallenge-club-64b7c608210e55b5564fe44df68d1eacf6d25969.tar.bz2
perlweeklychallenge-club-64b7c608210e55b5564fe44df68d1eacf6d25969.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-212/eric-cheung/python')
-rwxr-xr-xchallenge-212/eric-cheung/python/ch-1.py22
-rwxr-xr-xchallenge-212/eric-cheung/python/ch-2.py23
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)