aboutsummaryrefslogtreecommitdiff
path: root/challenge-273/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-273/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-273/eric-cheung/python/ch-2.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-273/eric-cheung/python/ch-2.py b/challenge-273/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..2b9c57d362
--- /dev/null
+++ b/challenge-273/eric-cheung/python/ch-2.py
@@ -0,0 +1,15 @@
+
+## strInput = "aabb" ## Example 1
+## strInput = "abab" ## Example 2
+## strInput = "aaa" ## Example 3
+strInput = "bbb" ## Example 4
+
+if strInput.count("b") <= 1:
+ print (False)
+else:
+ nFirstBPos = strInput.index("b")
+
+ nNumOfA = strInput[nFirstBPos + 1:].count("a")
+ nNumOfB = strInput[nFirstBPos + 1:].count("b")
+
+ print (nNumOfA == 0 and nNumOfB > 0)