aboutsummaryrefslogtreecommitdiff
path: root/challenge-226/robert-dicicco/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-226/robert-dicicco/python/ch-1.py')
-rw-r--r--challenge-226/robert-dicicco/python/ch-1.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/challenge-226/robert-dicicco/python/ch-1.py b/challenge-226/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..3165ac0efb
--- /dev/null
+++ b/challenge-226/robert-dicicco/python/ch-1.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+'''
+--------------------------------------
+AUTHOR: Robert DiCicco
+DATE : 2023-07-19
+Challenge 226 Task 1 Shuffle String ( Python )
+--------------------------------------
+'''
+strings = ["lacelengh", "rulepark"]
+indices = [[3,2,0,5,4,8,6,7,1],[4,7,3,1,0,5,2,6]]
+
+offset = 0
+cnt = 0
+
+
+for str in strings:
+ ndx = indices[offset]
+ print(f"Input: $string = {str}, @indices = {indices[offset]}")
+ cnt = 0
+ ln = len(str)
+ letters = dict()
+ while cnt < ln:
+ letter = str[cnt:cnt+1]
+ x = ndx[cnt]
+ letters[x] = letter
+ cnt += 1
+ cnt = 0
+ print("Output: ", end="");
+ while cnt < ln:
+ print(letters[cnt], end="")
+ cnt += 1
+ print("\n")
+ offset += 1
+
+'''
+--------------------------------------
+SAMPLE OUTPUT
+python .\ShuffleString.py
+
+Input: $string = lacelengh, @indices = [3, 2, 0, 5, 4, 8, 6, 7, 1]
+Output: challenge
+
+Input: $string = rulepark, @indices = [4, 7, 3, 1, 0, 5, 2, 6]
+Output: perlraku
+--------------------------------------
+'''
+
+