aboutsummaryrefslogtreecommitdiff
path: root/challenge-279/zapwai/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-279/zapwai/python')
-rw-r--r--challenge-279/zapwai/python/ch-1.py18
-rw-r--r--challenge-279/zapwai/python/ch-2.py24
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-279/zapwai/python/ch-1.py b/challenge-279/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..7490c50a5f
--- /dev/null
+++ b/challenge-279/zapwai/python/ch-1.py
@@ -0,0 +1,18 @@
+def proc(l, w):
+ print("Input: letters =", l, "weights =", w)
+ ans = []
+ for i in range(len(l)):
+ ans.append("")
+ for i in range(len(l)):
+ ans[w[i] - 1] = l[i]
+ print("Output: ", ans)
+
+letters = ['R', 'E', 'P', 'L']
+weights = [3, 2, 1, 4]
+proc(letters, weights)
+letters = ['A', 'U', 'R', 'K']
+weights = [2, 4, 1, 3]
+proc(letters, weights)
+letters = ['O', 'H', 'Y', 'N', 'P', 'T']
+weights = [5, 4, 2, 6, 1, 3]
+proc(letters, weights)
diff --git a/challenge-279/zapwai/python/ch-2.py b/challenge-279/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..b8b25daeeb
--- /dev/null
+++ b/challenge-279/zapwai/python/ch-2.py
@@ -0,0 +1,24 @@
+def is_vowel(c):
+ if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
+ return True
+ return False
+
+def proc(mystr):
+ print("Input: mystr =", mystr)
+ cnt = 0
+ for c in list(mystr):
+ if is_vowel(c):
+ cnt += 1
+
+ if cnt % 2 == 0:
+ print("Output: true")
+ else:
+ print("Output: false")
+
+mystr = "perl"
+proc(mystr)
+mystr = "book"
+proc(mystr)
+mystr = "goodmorning"
+proc(mystr)
+