aboutsummaryrefslogtreecommitdiff
path: root/challenge-275/zapwai/python/ch-2.py
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-06-25 14:52:59 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-06-25 14:52:59 -0400
commit9176b5be1ef39da532650c77b4df098f2a2a448e (patch)
treeac8647fa9fa5ed4e3b6ba494b9f7bc1356909e28 /challenge-275/zapwai/python/ch-2.py
parentb07b0b03e415426e49e0c43f71de0a27a3cc65a4 (diff)
downloadperlweeklychallenge-club-9176b5be1ef39da532650c77b4df098f2a2a448e.tar.gz
perlweeklychallenge-club-9176b5be1ef39da532650c77b4df098f2a2a448e.tar.bz2
perlweeklychallenge-club-9176b5be1ef39da532650c77b4df098f2a2a448e.zip
Week 275
Diffstat (limited to 'challenge-275/zapwai/python/ch-2.py')
-rw-r--r--challenge-275/zapwai/python/ch-2.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-275/zapwai/python/ch-2.py b/challenge-275/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..c593ac08fb
--- /dev/null
+++ b/challenge-275/zapwai/python/ch-2.py
@@ -0,0 +1,31 @@
+def shifty(c, d):
+ alph = 'abcdefghijklmnopqrstuvwxyz'
+ ind = alph.index(c)
+ A = list(alph)
+ return A[d + ind]
+
+def proc(stringy):
+ print("Input: str =", stringy);
+ lets = []
+ puts = []
+ for i in range(len(stringy)):
+ if i % 2 == 0:
+ let = stringy[i:i+1]
+ lets.append(let)
+ else:
+ put = shifty(lets[-1], ord(stringy[i:i+1]) - 48)
+ puts.append(put)
+ print("Output: ", end='')
+ for j in range((len(stringy)//2) ):
+ print(lets[j], puts[j], end='', sep='')
+ if (len(stringy)) % 2 == 1:
+ print(lets[-1], end='')
+ print("\n")
+
+stringy = 'a1c1e1'
+proc(stringy)
+stringy = 'a1b2c3d4'
+proc(stringy)
+stringy = 'b2b'
+proc(stringy)
+