aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/pokgopun/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-255/pokgopun/python/ch-1.py')
-rw-r--r--challenge-255/pokgopun/python/ch-1.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/challenge-255/pokgopun/python/ch-1.py b/challenge-255/pokgopun/python/ch-1.py
new file mode 100644
index 0000000000..c48ab19023
--- /dev/null
+++ b/challenge-255/pokgopun/python/ch-1.py
@@ -0,0 +1,49 @@
+### https://theweeklychallenge.org/blog/perl-weekly-challenge-255/
+"""
+
+Task 1: Odd Character
+
+Submitted by: [46]Mohammad Sajid Anwar
+ __________________________________________________________________
+
+ You are given two strings, $s and $t. The string $t is generated using
+ the shuffled characters of the string $s with an additional character.
+
+ Write a script to find the additional character in the string $t..
+
+Example 1
+
+Input: $s = "Perl" $t = "Preel"
+Output: "e"
+
+Example 2
+
+Input: $s = "Weekly" $t = "Weeakly"
+Output: "a"
+
+Example 3
+
+Input: $s = "Box" $t = "Boxy"
+Output: "y"
+
+Task 2: Most Frequent Word
+"""
+### solution by pokgopun@gmail.com
+
+def oddChar(s,t: str):
+ for c in s:
+ t = t.replace(c,"",1)
+ return t
+
+import unittest
+
+class TestOddChar(unittest.TestCase):
+ def test(self):
+ for (s,t), otpt in {
+ ("Perl","Preel"): "e",
+ ("Weekly","Weeakly"): "a",
+ ("Box","Boxy"): "y",
+ }.items():
+ self.assertEqual(oddChar(s,t), otpt)
+
+unittest.main()