diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-07-08 14:38:44 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-07-08 14:38:44 +0100 |
| commit | 40125a7671e65336f2b00e5dd385015ea62d51f3 (patch) | |
| tree | 2499db6c994ab7b73d5411f115a5a232d881f34d /challenge-277/eric-cheung/python | |
| parent | 4fefb9a739b7cf52eaa21886032dbb869db63c13 (diff) | |
| download | perlweeklychallenge-club-40125a7671e65336f2b00e5dd385015ea62d51f3.tar.gz perlweeklychallenge-club-40125a7671e65336f2b00e5dd385015ea62d51f3.tar.bz2 perlweeklychallenge-club-40125a7671e65336f2b00e5dd385015ea62d51f3.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke.
- Added solutions by PokGoPun.
- Added solutions by Niels van Dijke.
- Added solutions by Mark Anderson.
- Added solutions by Feng Chang.
Diffstat (limited to 'challenge-277/eric-cheung/python')
| -rwxr-xr-x | challenge-277/eric-cheung/python/ch-1.py | 16 | ||||
| -rwxr-xr-x | challenge-277/eric-cheung/python/ch-2.py | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-277/eric-cheung/python/ch-1.py b/challenge-277/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..c08ac8a721 --- /dev/null +++ b/challenge-277/eric-cheung/python/ch-1.py @@ -0,0 +1,16 @@ +
+## Example 1
+## arrWords_01 = ["Perl", "is", "my", "friend"]
+## arrWords_02 = ["Perl", "and", "Raku", "are", "friend"]
+
+## Example 2
+## arrWords_01 = ["Perl", "and", "Python", "are", "very", "similar"]
+## arrWords_02 = ["Python", "is", "top", "in", "guest", "languages"]
+
+## Example 3
+arrWords_01 = ["Perl", "is", "imperative", "Lisp", "is", "functional"]
+arrWords_02 = ["Crystal", "is", "similar", "to", "Ruby"]
+
+arrOutput = [strLoop for strLoop in set(arrWords_01 + arrWords_02) if arrWords_01.count(strLoop) == 1 and arrWords_02.count(strLoop) == 1]
+
+print (len(arrOutput))
diff --git a/challenge-277/eric-cheung/python/ch-2.py b/challenge-277/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..72b8faa3f6 --- /dev/null +++ b/challenge-277/eric-cheung/python/ch-2.py @@ -0,0 +1,16 @@ +
+from itertools import combinations
+
+def IsStrongPair (arrInput):
+ if abs(arrInput[0] - arrInput[1]) > 0 and min(arrInput) > abs(arrInput[0] - arrInput[1]):
+ return True
+ return False
+
+## arrInt = [1, 2, 3, 4, 5] ## Example 1
+arrInt = [5, 7, 1, 7] ## Example 2
+
+arrComb = combinations(arrInt, 2)
+
+arrOutput = [arrLoop for arrLoop in list(set(arrComb)) if IsStrongPair(arrLoop)]
+
+print (len(arrOutput))
|
