diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-01 14:44:14 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2024-01-01 14:44:14 +0000 |
| commit | 35cd0ec65acdd3a2c925c3a5d3a193bd307cdc5a (patch) | |
| tree | e270530cc19dd2ca16532fc6caf5d8c5f035f8a6 /challenge-250/eric-cheung/python | |
| parent | 0bea5e0b6e1e3bdc0906981495ebd9dd4cfc707e (diff) | |
| download | perlweeklychallenge-club-35cd0ec65acdd3a2c925c3a5d3a193bd307cdc5a.tar.gz perlweeklychallenge-club-35cd0ec65acdd3a2c925c3a5d3a193bd307cdc5a.tar.bz2 perlweeklychallenge-club-35cd0ec65acdd3a2c925c3a5d3a193bd307cdc5a.zip | |
- Added solutions by David Ferrone.
- Added solutions by PokGoPun.
- Added solutions by Stephen G Lynn.
- Added solutions by Mark Anderson.
- Added solutions by Thomas Kohler.
- Added solutions by Peter Meszaros.
- Added solutions by Bob Lied.
Diffstat (limited to 'challenge-250/eric-cheung/python')
| -rwxr-xr-x | challenge-250/eric-cheung/python/ch-1.py | 10 | ||||
| -rwxr-xr-x | challenge-250/eric-cheung/python/ch-2.py | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/challenge-250/eric-cheung/python/ch-1.py b/challenge-250/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..3f0e3c37c1 --- /dev/null +++ b/challenge-250/eric-cheung/python/ch-1.py @@ -0,0 +1,10 @@ +
+## arrInt = [0, 1, 2] ## Example 1
+## arrInt = [4, 3, 2, 1] ## Example 2
+arrInt = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] ## Example 3
+
+arrOutput = [nIndx for nIndx in range(len(arrInt)) if nIndx % 10 == arrInt[nIndx]]
+if len(arrOutput) > 0:
+ print (arrOutput[0])
+else:
+ print (-1)
diff --git a/challenge-250/eric-cheung/python/ch-2.py b/challenge-250/eric-cheung/python/ch-2.py new file mode 100755 index 0000000000..43a7617ff9 --- /dev/null +++ b/challenge-250/eric-cheung/python/ch-2.py @@ -0,0 +1,9 @@ +
+def GetAlphaNumLen (strInput):
+ return int(strInput) if strInput.isnumeric() else len(strInput)
+
+## arrAlphaNumStr = ["perl", "2", "000", "python", "r4ku"] ## Example 1
+arrAlphaNumStr = ["001", "1", "000", "0001"] ## Example 2
+
+arrOutput = [GetAlphaNumLen(strLoop) for strLoop in arrAlphaNumStr]
+print (max(arrOutput))
|
