aboutsummaryrefslogtreecommitdiff
path: root/challenge-275/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-275/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-275/eric-cheung/python/ch-2.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-275/eric-cheung/python/ch-2.py b/challenge-275/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..c243ed3899
--- /dev/null
+++ b/challenge-275/eric-cheung/python/ch-2.py
@@ -0,0 +1,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))