aboutsummaryrefslogtreecommitdiff
path: root/challenge-207/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-207/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-207/eric-cheung/python/ch-1.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-207/eric-cheung/python/ch-1.py b/challenge-207/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..57ddd9e817
--- /dev/null
+++ b/challenge-207/eric-cheung/python/ch-1.py
@@ -0,0 +1,30 @@
+
+arrKeyBoardRow = ["qwertyuiop", "asdfghjkl", "zxcvbnm"]
+
+arrInputWords = ["Hello", "Alaska", "Dad", "Peace"] ## Example 1
+## arrInputWords = ["OMG", "Bye"] ## Example 2
+
+arrKeyBoardChar = []
+for arrLoop in arrKeyBoardRow:
+ arrKeyBoardChar.append(list(arrLoop))
+
+arrOutputWords = []
+
+for arrLoop in arrInputWords:
+
+ strLoopLower = arrLoop.lower()
+
+ for nIndx in range(0, len(arrKeyBoardChar)):
+ if strLoopLower[0] in arrKeyBoardChar[nIndx]:
+ break
+
+ bSameRow = True
+ for nLoop in range(1, len(arrLoop)):
+ if strLoopLower[nLoop] not in arrKeyBoardChar[nIndx]:
+ bSameRow = False
+ break
+
+ if bSameRow:
+ arrOutputWords.append(arrLoop)
+
+print (arrOutputWords)