aboutsummaryrefslogtreecommitdiff
path: root/challenge-289/zapwai/python/ch-2.py
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-09-30 13:05:24 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-09-30 13:05:24 -0400
commitef99aabc641bef7ebe24b809e401babda7dfc5fe (patch)
tree97e5453f91b96bd94a4d716c09a59c4a010fa3a7 /challenge-289/zapwai/python/ch-2.py
parentfb4ae25cbf52df4ae59b5b7dfbd32004b67be604 (diff)
downloadperlweeklychallenge-club-ef99aabc641bef7ebe24b809e401babda7dfc5fe.tar.gz
perlweeklychallenge-club-ef99aabc641bef7ebe24b809e401babda7dfc5fe.tar.bz2
perlweeklychallenge-club-ef99aabc641bef7ebe24b809e401babda7dfc5fe.zip
Week 289
Diffstat (limited to 'challenge-289/zapwai/python/ch-2.py')
-rw-r--r--challenge-289/zapwai/python/ch-2.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-289/zapwai/python/ch-2.py b/challenge-289/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..f5bd6b88fc
--- /dev/null
+++ b/challenge-289/zapwai/python/ch-2.py
@@ -0,0 +1,28 @@
+import random
+
+def jumble(word) :
+ if len(word) < 4:
+ return word
+ let = list(word)
+ start = let[0]
+ end = let[len(let) - 1]
+ let = let[1:-1]
+ order = []
+ while (len(order) < len(let)) :
+ x = random.randint(0, len(let) - 1)
+ if x not in order:
+ order.append(x)
+ middle = ""
+ for i in order:
+ middle += let[i]
+ q = start + middle + end
+ return q
+
+def proc(s) :
+ print( "Input:", s)
+ words = s.split(" ")
+ new = ' '.join(map(jumble, words))
+ print( "Output:", new)
+
+s = "This supposed Cambridge research is unfortunately an urban legend"
+proc(s)