diff options
| author | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-08 17:15:53 +0100 |
|---|---|---|
| committer | Mohammad Sajid Anwar <mohammad.anwar@yahoo.com> | 2025-07-08 17:15:53 +0100 |
| commit | 09ded88c0f22d977cc3ce8163855b48bf0aec03b (patch) | |
| tree | d17b81f62c5153c70b32ac7ad8bd2ef2ab48fd2a /challenge-329/eric-cheung/python | |
| parent | eb91b5ca3d9f162b147ba570df3aec568fe4cadb (diff) | |
| download | perlweeklychallenge-club-09ded88c0f22d977cc3ce8163855b48bf0aec03b.tar.gz perlweeklychallenge-club-09ded88c0f22d977cc3ce8163855b48bf0aec03b.tar.bz2 perlweeklychallenge-club-09ded88c0f22d977cc3ce8163855b48bf0aec03b.zip | |
- Added solutions by Andrew Shitov.
- Added solutions by E. Choroba.
- Added solutions by Mark Anderson.
- Added solutions by Alexander Karelas.
- Added solutions by Simon Proctor.
- Added solutions by Peter Campbell Smith.
- Added solutions by PokGoPun.
- Added solutions by W. Luis Mochan.
- Added solutions by Wanderdoc.
- Added solutions by Peter Meszaros.
- Added solutions by Niels van Dijke.
- Added solutions by Thomas Kohler.
- Added solutions by Benjamin Andre.
- Added solutions by Feng Chang.
- Added solutions by Yitzchak Scott-Thoennes.
- Added solutions by Ali Moradi.
- Added solutions by David Ferrone.
- Added solutions by Kjetil Skotheim.
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))
|
