aboutsummaryrefslogtreecommitdiff
path: root/challenge-308/steven-wilson/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-02-12 18:24:36 +0000
committerGitHub <noreply@github.com>2025-02-12 18:24:36 +0000
commit578e20d72e394a9bdd4efc93fde8cee2e3528eb5 (patch)
tree3f2851e28494f5469ab62a3650cb57f92e3ad8a8 /challenge-308/steven-wilson/python/ch-1.py
parentaf273413c5cbadb34ce8187df7c957de99541ca2 (diff)
parent4e45c44c570fd4a77a5a76236bb763d4d9b859ec (diff)
downloadperlweeklychallenge-club-578e20d72e394a9bdd4efc93fde8cee2e3528eb5.tar.gz
perlweeklychallenge-club-578e20d72e394a9bdd4efc93fde8cee2e3528eb5.tar.bz2
perlweeklychallenge-club-578e20d72e394a9bdd4efc93fde8cee2e3528eb5.zip
Merge pull request #11567 from oWnOIzRi/week308
add solutions week 308 in python & perl
Diffstat (limited to 'challenge-308/steven-wilson/python/ch-1.py')
-rw-r--r--challenge-308/steven-wilson/python/ch-1.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-308/steven-wilson/python/ch-1.py b/challenge-308/steven-wilson/python/ch-1.py
new file mode 100644
index 0000000000..64274dd5cc
--- /dev/null
+++ b/challenge-308/steven-wilson/python/ch-1.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+
+def count_common(strings1, strings2):
+ """ Given two array of strings, return the count of common strings in both
+ arrays.
+ >>> count_common(("perl", "weekly", "challenge"), ("raku", "weekly", "challenge"))
+ 2
+ >>> count_common(("perl", "raku", "python"), ("python", "java"))
+ 1
+ >>> count_common(("guest", "contribution"), ("fun", "weekly", "challenge"))
+ 0
+ """
+ return len(set(strings1).intersection(strings2))
+
+
+if __name__ == "__main__":
+ import doctest
+
+ doctest.testmod(verbose=True)