aboutsummaryrefslogtreecommitdiff
path: root/challenge-335/deadmarshal/python/ch1.py
diff options
context:
space:
mode:
authorAli <adeadmarshal@gmail.com>2025-08-19 10:07:57 +0330
committerAli <adeadmarshal@gmail.com>2025-08-19 10:07:57 +0330
commite8aeeee6722902fd02c0c6ba244738acac8fa983 (patch)
treeaeb7c33905b7d875f028196ec4c14777d9b83ec1 /challenge-335/deadmarshal/python/ch1.py
parent4f766edf1327ad3628c824c3c00f1c1f10c50b38 (diff)
downloadperlweeklychallenge-club-e8aeeee6722902fd02c0c6ba244738acac8fa983.tar.gz
perlweeklychallenge-club-e8aeeee6722902fd02c0c6ba244738acac8fa983.tar.bz2
perlweeklychallenge-club-e8aeeee6722902fd02c0c6ba244738acac8fa983.zip
TWC335
Diffstat (limited to 'challenge-335/deadmarshal/python/ch1.py')
-rw-r--r--challenge-335/deadmarshal/python/ch1.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-335/deadmarshal/python/ch1.py b/challenge-335/deadmarshal/python/ch1.py
new file mode 100644
index 0000000000..c6eff24177
--- /dev/null
+++ b/challenge-335/deadmarshal/python/ch1.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+from collections import Counter
+
+def common_characters(words):
+ char_count = Counter(words[0])
+
+ for w in words:
+ current_count = Counter(w)
+
+ for c in list(char_count):
+ char_count[c] = min(char_count[c],current_count[c])
+
+ res = []
+
+ for char,count in char_count.items():
+ res.extend([char] * count)
+
+ return res
+
+
+print(common_characters(["bella","label","roller"]))
+print(common_characters(["cool","lock","cook"]))
+print(common_characters(["hello","world","pole"]))
+print(common_characters(["abc","def","ghi"]))
+print(common_characters(["aab","aac","aaa"]))
+