From 26d3aa51bc50bdd800d2a4b9556120d94a5f99af Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 29 Nov 2022 10:40:34 +0000 Subject: - Added guest contributions by Eric Cheung. --- challenge-193/eric-cheung/python/ch-1.py | 12 ++++++++++++ challenge-193/eric-cheung/python/ch-2.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 challenge-193/eric-cheung/python/ch-1.py create mode 100755 challenge-193/eric-cheung/python/ch-2.py diff --git a/challenge-193/eric-cheung/python/ch-1.py b/challenge-193/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..5b4ca78f08 --- /dev/null +++ b/challenge-193/eric-cheung/python/ch-1.py @@ -0,0 +1,12 @@ + +from itertools import product + +## nInput = 2 ## Example 1 +nInput = 3 ## Example 2 + +arrStrOutput = [] + +for arrIndx in product(range(2), repeat = nInput): + arrStrOutput.append("".join([str(nIndx) for nIndx in arrIndx])) + +print (arrStrOutput) diff --git a/challenge-193/eric-cheung/python/ch-2.py b/challenge-193/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..a28f7f0aac --- /dev/null +++ b/challenge-193/eric-cheung/python/ch-2.py @@ -0,0 +1,19 @@ + +def GetDiffStr(strInput): + return ",".join([str(ord(strInput[nIndx]) - ord(strInput[nIndx - 1])) for nIndx in range(1, len(strInput))]) + +## arrInputStr = ["adc", "wzy", "abc"] ## Example 1 +arrInputStr = ["aaa", "bob", "ccc", "ddd"] ## Example 2 + +arrStrAppend = [] +strOdd = "" + +for strLoop in arrInputStr: + arrStrAppend.append(GetDiffStr(strLoop)) + +for nIndxLoop, strLoop in enumerate(arrStrAppend): + if arrStrAppend.count(strLoop) == 1: + strOdd = arrInputStr[nIndxLoop] + break + +print (strOdd) -- cgit