diff options
Diffstat (limited to 'challenge-340/eric-cheung/python')
| -rwxr-xr-x | challenge-340/eric-cheung/python/ch-1.py | 19 | ||||
| -rwxr-xr-x | challenge-340/eric-cheung/python/ch-2.py | 12 |
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)
|
