diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-07-22 09:41:47 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2024-07-22 09:41:47 +0100 |
| commit | 7aff3f0a8f31701a7c8927fcbc41a9a194e4a157 (patch) | |
| tree | fcd7af15ba80eb99819cdd39bc8f73e3b7fbf28c /challenge-279/eric-cheung/python | |
| parent | 7a9ced4c8f5de3ab26a70e02883be0c457275a9c (diff) | |
| download | perlweeklychallenge-club-7aff3f0a8f31701a7c8927fcbc41a9a194e4a157.tar.gz perlweeklychallenge-club-7aff3f0a8f31701a7c8927fcbc41a9a194e4a157.tar.bz2 perlweeklychallenge-club-7aff3f0a8f31701a7c8927fcbc41a9a194e4a157.zip | |
- Added solutions by Eric Cheung.
Diffstat (limited to 'challenge-279/eric-cheung/python')
| -rwxr-xr-x | challenge-279/eric-cheung/python/ch-1.py | 18 | ||||
| -rwxr-xr-x | challenge-279/eric-cheung/python/ch-2.py | 10 |
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-279/eric-cheung/python/ch-1.py b/challenge-279/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..50d0bbbc82 --- /dev/null +++ b/challenge-279/eric-cheung/python/ch-1.py @@ -0,0 +1,18 @@ +
+## Example 1
+## arrLetters = ["R", "E", "P", "L"]
+## arrWeights = [3, 2, 1, 4]
+
+## Example 2
+## arrLetters = ["A", "U", "R", "K"]
+## arrWeights = [2, 4, 1, 3]
+
+## Example 3
+arrLetters = ["O", "H", "Y", "N", "P", "T"]
+arrWeights = [5, 4, 2, 6, 1, 3]
+
+arrSort = sorted([[nWeightLoop, charLoop] for charLoop, nWeightLoop in zip(arrLetters, arrWeights)])
+
+strOutput = "".join([charLoop for nWeightLoop, charLoop in arrSort])
+
+print (strOutput)
diff --git a/challenge-279/eric-cheung/python/ch-2.py b/challenge-279/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..c413351d9a --- /dev/null +++ b/challenge-279/eric-cheung/python/ch-2.py @@ -0,0 +1,10 @@ +
+## strInput = "perl" ## Example 1
+## strInput = "book" ## Example 2
+strInput = "good morning" ## Example 3
+
+arrVowel = ["a", "e", "i", "o", "u"]
+
+arrVowelCount = [charLoop for charLoop in strInput if charLoop in arrVowel]
+
+print (len(arrVowelCount) % 2 == 0)
|
