aboutsummaryrefslogtreecommitdiff
path: root/challenge-275/eric-cheung/python/ch-2.py
blob: c243ed38990ab7ade5170bac48dd5831b15d43ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
## strInput = "a1c1e1"  ## Example 1
## strInput = "a1b2c3d4"  ## Example 2
## strInput = "b2b"  ## Example 3
strInput = "a16z"  ## Example 4

arrList = list(strInput)
arrPosNum = [nIndx for nIndx, charLoop in enumerate(strInput) if charLoop.isdigit()]
arrPosChar = [nIndx for nIndx, charLoop in enumerate(strInput) if charLoop.isalpha()]

## print (arrPosNum)
## print (arrPosChar)

for nIndx in arrPosNum:
    LastChar = strInput[[nLoop for nLoop in arrPosChar if nLoop < nIndx][-1]]
    arrList[nIndx] = chr(ord(LastChar) + int(arrList[nIndx]))

print ("".join(arrList))