aboutsummaryrefslogtreecommitdiff
path: root/challenge-255/lubos-kolouch/python/ch-1.py
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2024-02-09 15:28:55 +0100
committerLubos Kolouch <lubos@kolouch.net>2024-02-09 15:28:55 +0100
commit20ccf25c6944641c7db4b60fa15d520686cb7036 (patch)
tree0da9d3de4f285dafb23bbcb0fbecf6c80e87f384 /challenge-255/lubos-kolouch/python/ch-1.py
parent399287fcd1fa2800c9ab44b9a065116e9a55ec86 (diff)
downloadperlweeklychallenge-club-20ccf25c6944641c7db4b60fa15d520686cb7036.tar.gz
perlweeklychallenge-club-20ccf25c6944641c7db4b60fa15d520686cb7036.tar.bz2
perlweeklychallenge-club-20ccf25c6944641c7db4b60fa15d520686cb7036.zip
feat(challenge-255/lubos-kolouch/perl,python,raku/): Challenge 255 LK Perl Python Raku
Diffstat (limited to 'challenge-255/lubos-kolouch/python/ch-1.py')
-rw-r--r--challenge-255/lubos-kolouch/python/ch-1.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-255/lubos-kolouch/python/ch-1.py b/challenge-255/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..b09f8ab050
--- /dev/null
+++ b/challenge-255/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,24 @@
+def find_odd_character(s: str, t: str) -> str:
+ """
+ Finds the additional character in string t.
+
+ :param s: Original string.
+ :param t: Modified string with one extra character.
+ :return: The additional character.
+ """
+ from collections import Counter
+
+ count_s = Counter(s)
+ count_t = Counter(t)
+
+ for char in count_t:
+ if count_t[char] > count_s.get(char, 0):
+ return char
+
+ return ""
+
+
+# Tests
+assert find_odd_character("Perl", "Preel") == "e"
+assert find_odd_character("Weekly", "Weeakly") == "a"
+assert find_odd_character("Box", "Boxy") == "y"