aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/eric-cheung/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-215/eric-cheung/python')
-rwxr-xr-xchallenge-215/eric-cheung/python/ch-1.py16
-rwxr-xr-xchallenge-215/eric-cheung/python/ch-2.py26
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-215/eric-cheung/python/ch-1.py b/challenge-215/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..1398ab8a04
--- /dev/null
+++ b/challenge-215/eric-cheung/python/ch-1.py
@@ -0,0 +1,16 @@
+
+## arrWordInput = ['abc', 'xyz', 'tsu'] ## Example 1
+## arrWordInput = ['rat', 'cab', 'dad'] ## Example 2
+arrWordInput = ['x', 'y', 'z'] ## Example 3
+
+arrRemovedWord = []
+
+for strWordLoop in arrWordInput:
+
+ strSortWordLoop = ''.join(sorted(strWordLoop))
+ if strWordLoop == strSortWordLoop:
+ continue
+
+ arrRemovedWord.append(strWordLoop)
+
+print (len(arrRemovedWord))
diff --git a/challenge-215/eric-cheung/python/ch-2.py b/challenge-215/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..8c366a73f6
--- /dev/null
+++ b/challenge-215/eric-cheung/python/ch-2.py
@@ -0,0 +1,26 @@
+
+## Example 1
+## arrNum = [1, 0, 0, 0, 1]
+## nCount = 1
+
+## Example 2
+## arrNum = [1, 0, 0, 0, 1]
+## nCount = 2
+
+## Example 3
+arrNum = [1, 0, 0, 0, 0, 0, 0, 0, 1]
+nCount = 3
+
+for nIndxLoop in range(1, len(arrNum) - 1):
+
+ if nCount == 0:
+ break
+
+ if arrNum[nIndxLoop - 1] == 0 and arrNum[nIndxLoop] == 0 and arrNum[nIndxLoop + 1] == 0:
+ arrNum[nIndxLoop] = 1
+ nCount = nCount - 1
+
+if nCount == 0:
+ print (1)
+else:
+ print (0)