From a0ea2c78c8ac2bb33fb79ab151f86b3beb143647 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 8 Mar 2023 23:32:11 +0000 Subject: - Added solutions by Avery Adams. - Added solutions by Jaldhar H. Vyas. - Added solutions by Mark Anderson. - Added solutions by Luca Ferrari. - Added solutions by Peter Campbell Smith. - Added solutions by W. Luis Mochan. - Added solutions by Paulo Custodio. - Added solutions by Cheok-Yin Fung. - Added solutions by E. Choroba. - Added solutions by Bob Lied. - Added solutions by Robbie Hatley. - Added solutions by Matthias Muth. - Added solutions by Lubos Kolouch. - Added solutions by Solathian. - Added solutions by Duncan C. White. - Added solutions by Kjetil Skotheim. - Added solutions by Marton Polgar. - Added solutions by David Ferrone. - Added solutions by Mariano Spadaccini. - Added solutions by Robert DiCicco. - Added solutions by Ulrich Rieke. - Added solutions by Laurent Rosenfeld. --- challenge-207/eric-cheung/python/ch-1.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 challenge-207/eric-cheung/python/ch-1.py (limited to 'challenge-207/eric-cheung/python/ch-1.py') 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) -- cgit