aboutsummaryrefslogtreecommitdiff
path: root/challenge-340/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-09-23 00:04:07 +0100
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-09-23 00:04:07 +0100
commit30b12921af1cb617911d9afbcb55b3d947bd2f8a (patch)
tree8f0306f3bcc951a5bf2941dc6c1979dd1de1ac06 /challenge-340/eric-cheung/python
parent51307d1b8af8ceaeba0a859c6a17e6ace6f68032 (diff)
downloadperlweeklychallenge-club-30b12921af1cb617911d9afbcb55b3d947bd2f8a.tar.gz
perlweeklychallenge-club-30b12921af1cb617911d9afbcb55b3d947bd2f8a.tar.bz2
perlweeklychallenge-club-30b12921af1cb617911d9afbcb55b3d947bd2f8a.zip
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke. - Added solutions by Andrew Shitov. - Added solutions by Mark Anderson. - Added solutions by Feng Chang. - Added solutions by Niels van Dijke. - Added solutions by PokGoPun. - Added solutions by E. Choroba. - Added solutions by Andreas Mahnke. - Added solutions by Simon Proctor. - Added solutions by Lubos Kolouch. - Added solutions by Richard Park. - Added solutions by Conor Hoekstra. - Added solutions by David Ferrone. - Added solutions by Bob Lied. - Added solutions by Peter Campbell Smith. - Added solutions by W. Luis Mochan. - Added solutions by Benjamin Andre. - Added solutions by Wanderdoc. - Added solutions by Thomas Kohler.
Diffstat (limited to 'challenge-340/eric-cheung/python')
-rwxr-xr-xchallenge-340/eric-cheung/python/ch-1.py19
-rwxr-xr-xchallenge-340/eric-cheung/python/ch-2.py12
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-340/eric-cheung/python/ch-1.py b/challenge-340/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..d1bf6f5b4a
--- /dev/null
+++ b/challenge-340/eric-cheung/python/ch-1.py
@@ -0,0 +1,19 @@
+
+## strInput = "abbaca" ## Example 1
+## strInput = "azxxzy" ## Example 2
+## strInput = "aaaaaaaa" ## Example 3
+## strInput = "aabccba" ## Example 4
+strInput = "abcddcba" ## Example 5
+
+arrOutput = list(strInput)
+
+nIndx = 1
+while nIndx < len(arrOutput):
+ if arrOutput[nIndx] == arrOutput[nIndx - 1]:
+ arrOutput.pop(nIndx)
+ arrOutput.pop(nIndx - 1)
+ nIndx = 1
+ continue
+ nIndx = nIndx + 1
+
+print ("".join(arrOutput))
diff --git a/challenge-340/eric-cheung/python/ch-2.py b/challenge-340/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..c5de473983
--- /dev/null
+++ b/challenge-340/eric-cheung/python/ch-2.py
@@ -0,0 +1,12 @@
+
+## strInput = "The cat has 3 kittens 7 toys 10 beds" ## Example 1
+## strInput = "Alice bought 5 apples 2 oranges 9 bananas" ## Example 2
+## strInput = "I ran 1 mile 2 days 3 weeks 4 months" ## Example 3
+## strInput = "Bob has 10 cars 10 bikes" ## Example 4
+strInput = "Zero is 0 one is 1 two is 2" ## Example 5
+
+arrNum = [int(strLoop) for strLoop in strInput.split(" ") if strLoop.isnumeric()]
+
+bIsStrictIncrease = all([arrNum[nIndx] > arrNum[nIndx - 1] for nIndx in range(1, len(arrNum))])
+
+print (bIsStrictIncrease)