aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/packy-anderson/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-255/packy-anderson/python/ch-1.py')
-rwxr-xr-xchallenge-255/packy-anderson/python/ch-1.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-255/packy-anderson/python/ch-1.py b/challenge-255/packy-anderson/python/ch-1.py
new file mode 100755
index 0000000000..8d4e8b5ab7
--- /dev/null
+++ b/challenge-255/packy-anderson/python/ch-1.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import sys
+from collections import Counter
+
+def oddChar(s, t):
+ # count the characters in s
+ count = Counter()
+ for c in s.lower():
+ count[c] += 1
+
+ # find the character in t that's been added to s
+ for c in t.lower():
+ if c not in count:
+ # we found the added character!
+ return c
+ count[c] -= 1
+ if count[c] == 0:
+ del count[c]
+
+ sys.exit("No odd character found!")
+
+def solution(s, t):
+ print(f'Input: $s = "{s}" $t = "{t}"')
+ o = oddChar(s, t)
+ print(f'Output: "{o}"')
+
+print('Example 1:')
+solution("Perl", "Preel")
+
+print('\nExample 2:')
+solution("Weekly", "Weeakly")
+
+print('\nExample 3:')
+solution("Box", "Boxy") \ No newline at end of file