aboutsummaryrefslogtreecommitdiff
path: root/challenge-212/eric-cheung/python/ch-1.py
blob: f7a2780aed7434806ea022eaebba4683ec6894c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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))