diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-11-09 20:26:45 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-11-09 20:26:45 +0000 |
| commit | 6820ca60cd19b1148ac5eef495b0a172d0426f32 (patch) | |
| tree | 1300d857e8e2e64a84f7b5627b7df6427dd418a3 | |
| parent | 2b107c0a1007dc904822ac1a2c19d76d697fc559 (diff) | |
| download | perlweeklychallenge-club-6820ca60cd19b1148ac5eef495b0a172d0426f32.tar.gz perlweeklychallenge-club-6820ca60cd19b1148ac5eef495b0a172d0426f32.tar.bz2 perlweeklychallenge-club-6820ca60cd19b1148ac5eef495b0a172d0426f32.zip | |
- Added guest contributions by Eric Cheung.
| -rwxr-xr-x | challenge-190/eric-cheung/python/ch-1.py | 15 | ||||
| -rwxr-xr-x | challenge-190/eric-cheung/python/ch-2.py | 54 |
2 files changed, 69 insertions, 0 deletions
diff --git a/challenge-190/eric-cheung/python/ch-1.py b/challenge-190/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..0f32352a2d --- /dev/null +++ b/challenge-190/eric-cheung/python/ch-1.py @@ -0,0 +1,15 @@ +
+def IsApproCapital (strFuncInput):
+
+ if strFuncInput.islower() or strFuncInput.isupper() or strFuncInput[0].isupper() and strFuncInput[1:].islower():
+ return True
+
+ return False
+
+
+## strInput = "Perl" ## Example 1
+## strInput = "TPF" ## Example 2
+## strInput = "PyThon" ## Example 3
+strInput = "raku" ## Example 4
+
+print ("1" if IsApproCapital(strInput) else "0")
diff --git a/challenge-190/eric-cheung/python/ch-2.py b/challenge-190/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..cc9f934746 --- /dev/null +++ b/challenge-190/eric-cheung/python/ch-2.py @@ -0,0 +1,54 @@ +
+## Credit:
+## https://github.com/manwar/perlweeklychallenge-club/blob/master/challenge-190/roger-bell-west/python/ch-2.py
+
+from collections import deque
+
+def GetMap(strFuncInput):
+ return chr(int(strFuncInput) + 64)
+
+def GetStack(stackLeft, stackLeftTail, nLastPos):
+
+ stackCopy = stackLeft.copy()
+ stackCopy.append(stackLeftTail[0:nLastPos])
+ stackCopy.append(stackLeftTail[nLastPos:])
+
+ return stackCopy
+
+def decodedList(strFuncInput):
+ stackTemp = deque()
+ stackTemp.append([strFuncInput])
+ arrTempOutput = set()
+
+ while len(stackTemp) > 0:
+
+ stackTempPopLeft = stackTemp.popleft()
+ stackTempPopLeftTail = stackTempPopLeft.pop()
+
+ if len(stackTempPopLeftTail) == 0:
+ arrTempOutput.add(tuple(stackTempPopLeft))
+ continue
+
+ if stackTempPopLeftTail[0] != "0":
+ stackTemp.append(GetStack(stackTempPopLeft, stackTempPopLeftTail, 1))
+
+ if len(stackTempPopLeftTail) >= 2:
+ nCheckVal = int(stackTempPopLeftTail[0:2])
+ if nCheckVal >= 1 and nCheckVal <= 26:
+ stackTemp.append(GetStack(stackTempPopLeft, stackTempPopLeftTail, 2))
+
+ arrOuput = []
+
+ for elemLoop in arrTempOutput:
+ arrOuput.append("".join(GetMap(charLoop) for charLoop in elemLoop))
+
+ arrOuput.sort()
+
+ return arrOuput
+
+
+## strInput = "11" ## Example 1
+## strInput = "1115" ## Example 2
+strInput = "127" ## Example 3
+
+print (decodedList(strInput))
|
