aboutsummaryrefslogtreecommitdiff
path: root/challenge-274/zapwai/python
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-06-20 16:42:41 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-06-20 16:42:41 -0400
commit8ef5ca339458a84020cb28e58aed50e18720b40b (patch)
tree78c44541e20ad6c645f3ce4e01369c6b311b70ce /challenge-274/zapwai/python
parentffc47a8850ee877978e371d11a01a028862a3f9d (diff)
downloadperlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.tar.gz
perlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.tar.bz2
perlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.zip
Week 274
Diffstat (limited to 'challenge-274/zapwai/python')
-rw-r--r--challenge-274/zapwai/python/ch-1.py30
-rw-r--r--challenge-274/zapwai/python/ch-2.py32
2 files changed, 62 insertions, 0 deletions
diff --git a/challenge-274/zapwai/python/ch-1.py b/challenge-274/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..b1dcb7a1d2
--- /dev/null
+++ b/challenge-274/zapwai/python/ch-1.py
@@ -0,0 +1,30 @@
+def is_vowel(c):
+ return c.lower() in 'aeiou'
+
+def proc(sent):
+ print("Input: ", sent)
+ print("Output: ", end='')
+ words = sent.split(" ");
+ for i in range(len(words)):
+ A = ""
+ for j in range(i+1):
+ A += "a"
+ lets = list(words[i])
+ first_let = lets[0]
+ reword = ""
+ for k in range(1,len(lets)):
+ reword += lets[k]
+ reword += first_let
+ if is_vowel(first_let):
+ print(words[i]+"ma"+A+" ", end='')
+ else:
+ print(reword+"ma"+A+" ", end='')
+ print()
+
+sent = "I love Perl"
+proc(sent)
+sent = "Perl and Raku are friends"
+proc(sent)
+sent = "The Weekly Challenge"
+proc(sent)
+
diff --git a/challenge-274/zapwai/python/ch-2.py b/challenge-274/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..cef432da13
--- /dev/null
+++ b/challenge-274/zapwai/python/ch-2.py
@@ -0,0 +1,32 @@
+def delta(t, ran):
+ for r in (ran):
+ if r < t:
+ continue
+ return r - t
+ return 0
+inp = [ [12, 11, 41], [15, 5, 35] ]
+MAX = 60
+R = []
+cost = []
+for l in inp:
+ interval = l[0]
+ start = l[1]
+ cost.append(l[2])
+ L = []
+ for i in range(int(MAX/l[0])):
+ x = start + i*interval
+ L.append(x)
+ R.append(L)
+r1 = R[0]
+r2 = R[1]
+length_one = cost[0]
+length_two = cost[1]
+out = ""
+for t in range(1, MAX-1):
+ delta_one = delta(t, r1)
+ delta_two = delta(t, r2)
+ time_taken_one = length_one + delta_one
+ time_taken_two = length_two + delta_two
+ if (delta_one < delta_two) and (time_taken_one > time_taken_two):
+ out += str(t)+" "
+print(out)