diff options
Diffstat (limited to 'challenge-329/eric-cheung/python')
| -rwxr-xr-x | challenge-329/eric-cheung/python/ch-1.py | 10 | ||||
| -rwxr-xr-x | challenge-329/eric-cheung/python/ch-2.py | 39 |
2 files changed, 49 insertions, 0 deletions
diff --git a/challenge-329/eric-cheung/python/ch-1.py b/challenge-329/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..1768c4c152 --- /dev/null +++ b/challenge-329/eric-cheung/python/ch-1.py @@ -0,0 +1,10 @@ +
+## strInput = "the1weekly2challenge2" ## Example 1
+## strInput = "go21od1lu5c7k" ## Example 2
+strInput = "4p3e2r1l" ## Example 3
+
+strOutput = "".join([charLoop if charLoop.isnumeric() else " " for charLoop in strInput])
+
+arrOutput = set([int(strNumLoop) for strNumLoop in strOutput.split(" ") if strNumLoop])
+
+print (arrOutput)
diff --git a/challenge-329/eric-cheung/python/ch-2.py b/challenge-329/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..572cf81fcc --- /dev/null +++ b/challenge-329/eric-cheung/python/ch-2.py @@ -0,0 +1,39 @@ +
+def IsStrNice (strFunc):
+ arrFunc = set(list(strFunc))
+ strChar = strFunc[0]
+ return strChar.upper() in arrFunc and strChar.lower() in arrFunc
+
+## strInput = "YaaAho" ## Example 1
+## strInput = "cC" ## Example 2
+strInput = "A" ## Example 3
+
+arrTemp = []
+strTemp = strInput[0]
+
+for charLoop in strInput[1:]:
+ if charLoop.lower() == strTemp[-1].lower():
+ strTemp = strTemp + charLoop
+ else:
+ arrTemp.append(strTemp)
+ strTemp = charLoop
+
+arrTemp.append(strTemp)
+
+nMaxLen = 0
+arrOutput = []
+
+for strLoop in arrTemp:
+ if not IsStrNice(strLoop):
+ continue
+
+ if len(strLoop) < nMaxLen:
+ continue
+
+ if len(strLoop) > nMaxLen:
+ nMaxLen = len(strLoop)
+ arrOutput = [strLoop]
+ else:
+ arrOutput.append(strLoop)
+
+print (", ".join(arrOutput))
|
