From 30b12921af1cb617911d9afbcb55b3d947bd2f8a Mon Sep 17 00:00:00 2001 From: Mohammad Sajid Anwar Date: Tue, 23 Sep 2025 00:04:07 +0100 Subject: - 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. --- challenge-340/eric-cheung/python/ch-1.py | 19 +++++++++++++++++++ challenge-340/eric-cheung/python/ch-2.py | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 challenge-340/eric-cheung/python/ch-1.py create mode 100755 challenge-340/eric-cheung/python/ch-2.py (limited to 'challenge-340/eric-cheung/python') 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) -- cgit