blob: 57ddd9e81750f7e8618dbf0fd430a9beddbda167 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)
|