aboutsummaryrefslogtreecommitdiff
path: root/challenge-239
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-10-18 21:13:34 +0100
committerGitHub <noreply@github.com>2023-10-18 21:13:34 +0100
commit4dfce12881d15e7a865d838d4fd2a6b13c3834b8 (patch)
tree58ff2a9df0f5595537f76a13c8fbe21d934c9c7f /challenge-239
parent1fdf4a2d626e209bf7e2eb98de3f45c56a8cc5c9 (diff)
parenteb7fb4b3fbc612b9bc116599e2b69552bc1e99f3 (diff)
downloadperlweeklychallenge-club-4dfce12881d15e7a865d838d4fd2a6b13c3834b8.tar.gz
perlweeklychallenge-club-4dfce12881d15e7a865d838d4fd2a6b13c3834b8.tar.bz2
perlweeklychallenge-club-4dfce12881d15e7a865d838d4fd2a6b13c3834b8.zip
Merge pull request #8899 from oWnOIzRi/week239
add solutions week 239 in python
Diffstat (limited to 'challenge-239')
-rw-r--r--challenge-239/steven-wilson/python/ch-01.py20
-rw-r--r--challenge-239/steven-wilson/python/ch-02.py23
2 files changed, 43 insertions, 0 deletions
diff --git a/challenge-239/steven-wilson/python/ch-01.py b/challenge-239/steven-wilson/python/ch-01.py
new file mode 100644
index 0000000000..4175d383ad
--- /dev/null
+++ b/challenge-239/steven-wilson/python/ch-01.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python3
+
+
+def same_string(first, second):
+ '''
+ Is the word created by concatenating the array elements the same
+ >>> same_string(["ab", "c"], ["a", "bc"])
+ True
+ >>> same_string(["ab", "c"], ["ac", "b"])
+ False
+ >>> same_string(["ab", "cd", "e"], ["abcde"])
+ True
+ '''
+ return "".join(first) == "".join(second)
+
+
+if __name__ == "__main__":
+ import doctest
+
+ doctest.testmod()
diff --git a/challenge-239/steven-wilson/python/ch-02.py b/challenge-239/steven-wilson/python/ch-02.py
new file mode 100644
index 0000000000..288f88d417
--- /dev/null
+++ b/challenge-239/steven-wilson/python/ch-02.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+
+def consistent_strings(allowed, strings):
+ ''' return the number of consistent strings in the given array
+ >>> consistent_strings("ab", ("ad", "bd", "aaab", "baa", "badab"))
+ 2
+ >>> consistent_strings("abc", ("a", "b", "c", "ab", "ac", "bc", "abc"))
+ 7
+ >>> consistent_strings("cad", ("cc", "acd", "b", "ba", "bac", "bad", "ac", "d"))
+ 4
+ '''
+ count = 0
+ for string in strings:
+ if set(string).issubset(allowed):
+ count += 1
+ return count
+
+
+if __name__ == "__main__":
+ import doctest
+
+ doctest.testmod()