diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-15 11:10:21 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-15 11:10:21 +0100 |
| commit | 5cccfc981512e14a5bcee9964ff8391f2e4da93b (patch) | |
| tree | 0605df384edd3578c897d8d2b2839339aef0dfa6 /challenge-330/eric-cheung/python | |
| parent | 3e616005e0d5db730ff024ee15e9e66049bb3ed4 (diff) | |
| download | perlweeklychallenge-club-5cccfc981512e14a5bcee9964ff8391f2e4da93b.tar.gz perlweeklychallenge-club-5cccfc981512e14a5bcee9964ff8391f2e4da93b.tar.bz2 perlweeklychallenge-club-5cccfc981512e14a5bcee9964ff8391f2e4da93b.zip | |
- Added solutions by Mark Anderson.
- Added solutions by Feng Chang.
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke.
- Added solutions by Benjamin Andre.
- Added solutions by Ali Moradi.
- Added solutions by Andrew Shitov.
- Added solutions by E. Choroba.
- Added solutions by Lukas Mai.
- Added solutions by Simon Proctor.
- Added solutions by Adam Russell.
- Added solutions by David Ferrone.
- Added solutions by Luca Ferrari.
- Added solutions by Peter Campbell Smith.
- Added solutions by W. Luis Mochan.
- Added solutions by Conor Hoekstra.
- Added solutions by Thomas Kohler.
- Added solutions by Jaldhar H. Vyas.
- Added solutions by Roger Bell_West.
Diffstat (limited to 'challenge-330/eric-cheung/python')
| -rwxr-xr-x | challenge-330/eric-cheung/python/ch-1.py | 16 | ||||
| -rwxr-xr-x | challenge-330/eric-cheung/python/ch-2.py | 22 |
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-330/eric-cheung/python/ch-1.py b/challenge-330/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..7cb84e86b6 --- /dev/null +++ b/challenge-330/eric-cheung/python/ch-1.py @@ -0,0 +1,16 @@ +
+## strInput = "cab12" ## Example 1
+## strInput = "xy99" ## Example 2
+strInput = "pa1erl" ## Example 3
+
+arrInput = list(strInput)
+
+while len([charLoop for charLoop in arrInput if charLoop.isdigit()]) > 0:
+ nFirstNumDigit = [nIndx for nIndx, charLoop in enumerate(arrInput) if charLoop.isdigit()][0]
+ if nFirstNumDigit == 0:
+ break
+
+ del arrInput[nFirstNumDigit]
+ del arrInput[nFirstNumDigit - 1]
+
+print ("".join(arrInput))
diff --git a/challenge-330/eric-cheung/python/ch-2.py b/challenge-330/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..1ccef2a8d9 --- /dev/null +++ b/challenge-330/eric-cheung/python/ch-2.py @@ -0,0 +1,22 @@ +
+## strInput = "PERL IS gREAT" ## Example 1
+## strInput = "THE weekly challenge" ## Example 2
+strInput = "YoU ARE A stAR" ## Example 3
+
+## ==== METHOD 1 ====
+## arrOutput = []
+
+## for strLoop in strInput.split(" "):
+ ## if len(strLoop) < 3:
+ ## arrOutput.append(strLoop.lower())
+ ## else:
+ ## ## arrOutput.append(strLoop[0].upper() + strLoop[1:].lower())
+ ## arrOutput.append(strLoop.title())
+## ==== METHOD 1 ====
+
+## ==== METHOD 2 ====
+## arrOutput = [strLoop.lower() if len(strLoop) < 3 else strLoop[0].upper() + strLoop[1:].lower() for strLoop in strInput.split(" ")]
+arrOutput = [strLoop.lower() if len(strLoop) < 3 else strLoop.title() for strLoop in strInput.split(" ")]
+## ==== METHOD 2 ====
+
+print (" ".join(arrOutput))
|
