diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-02-13 01:29:34 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-02-13 01:29:34 +0000 |
| commit | 94d2ed24dcd44638355ac7c5084e05d8b8ca9f41 (patch) | |
| tree | c464d8b2de64858f820db20ffd1e4ca3989cca99 /challenge-256/eric-cheung/python | |
| parent | 5f9ad3eb76b08a6e2adbae41552dbeb88d122485 (diff) | |
| download | perlweeklychallenge-club-94d2ed24dcd44638355ac7c5084e05d8b8ca9f41.tar.gz perlweeklychallenge-club-94d2ed24dcd44638355ac7c5084e05d8b8ca9f41.tar.bz2 perlweeklychallenge-club-94d2ed24dcd44638355ac7c5084e05d8b8ca9f41.zip | |
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke.
- Added solutions by Laurent Rosenfeld.
- Added solutions by Ali Moradi.
- Added solutions by Mark Anderson.
- Added solutions by Niels van Dijke.
- Added solutions by E. Choroba.
- Added solutions by PokGoPun.
- Added solutions by Stephen G Lynn.
- Added solutions by Stevem Wilson.
- Added solutions by Peter Campbell Smith.
- Added solutions by Peter Meszaros.
- Added solutions by Andrew Shitov.
- Added solutions by Thomas Kohler.
- Added solutions by Matthew Neleigh.
- Added solutions by Arne Sommer.
Diffstat (limited to 'challenge-256/eric-cheung/python')
| -rwxr-xr-x | challenge-256/eric-cheung/python/ch-1.py | 8 | ||||
| -rwxr-xr-x | challenge-256/eric-cheung/python/ch-2.py | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-256/eric-cheung/python/ch-1.py b/challenge-256/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..7fad78fbe6 --- /dev/null +++ b/challenge-256/eric-cheung/python/ch-1.py @@ -0,0 +1,8 @@ +
+## arrWords = ["ab", "de", "ed", "bc"] ## Example 1
+## arrWords = ["aa", "ba", "cd", "ed"] ## Example 2
+arrWords = ["uv", "qp", "st", "vu", "mn", "pq"] ## Example 3
+
+arrOutput = [arrWords[nRowLoop] for nRowLoop in range(len(arrWords) - 1) for nColLoop in range(nRowLoop + 1, len(arrWords)) if arrWords[nRowLoop] == arrWords[nColLoop][::-1]]
+
+print (len(arrOutput))
diff --git a/challenge-256/eric-cheung/python/ch-2.py b/challenge-256/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..ca9867af98 --- /dev/null +++ b/challenge-256/eric-cheung/python/ch-2.py @@ -0,0 +1,17 @@ +
+## Example 1
+## strIn_01 = "abcd"
+## strIn_02 = "1234"
+
+## Example 2
+## strIn_01 = "abc"
+## strIn_02 = "12345"
+
+## Example 3
+strIn_01 = "abcde"
+strIn_02 = "123"
+
+nMinLen = min(len(strIn_01), len(strIn_02))
+strOutput = "".join([strLoop_01 + strLoop_02 for strLoop_01, strLoop_02 in zip(strIn_01[:nMinLen], strIn_02[:nMinLen])]) + (strIn_01[nMinLen:] if len(strIn_01) > len(strIn_02) else strIn_02[nMinLen:] if len(strIn_02) > len(strIn_01) else "")
+
+print (strOutput)
|
