aboutsummaryrefslogtreecommitdiff
path: root/challenge-250/eric-cheung/python/ch-1.py
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-08 19:15:36 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-08 19:15:36 +0000
commitda0d5dcf50f8fa8def91abaafce1fd5624ec1a61 (patch)
tree48d62d167588ce05b7ad7e5e2b321355d81a3f0f /challenge-250/eric-cheung/python/ch-1.py
parent066a38cc3004d179463b4c3cd5feb18b042ad36f (diff)
downloadperlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.gz
perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.tar.bz2
perlweeklychallenge-club-da0d5dcf50f8fa8def91abaafce1fd5624ec1a61.zip
i- Added solutions by Mark Anderson.
- Added solutions by PokGoPun. - Added solutions by Simon Proctor. - Added solutions by Luca Ferrari. - Added solutions by Thomas Kohler. - Added solutions by Peter Campbell Smith. - Added solutions by Niels van Dijke. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Dave Jacoby. - Added solutions by Peter Meszaros. - Added solutions by Laurent Rosenfeld.
Diffstat (limited to 'challenge-250/eric-cheung/python/ch-1.py')
-rwxr-xr-xchallenge-250/eric-cheung/python/ch-1.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/challenge-250/eric-cheung/python/ch-1.py b/challenge-250/eric-cheung/python/ch-1.py
index 3f0e3c37c1..66f88a07e9 100755
--- a/challenge-250/eric-cheung/python/ch-1.py
+++ b/challenge-250/eric-cheung/python/ch-1.py
@@ -1,10 +1,17 @@
-## 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)
+## arrInt = [6, 12, 25, 1] ## Example 1
+## arrInt = [10, 7, 31, 5, 2, 2] ## Example 2
+arrInt = [1, 2, 10] ## Example 3
+
+nSum = 0
+while len(arrInt) > 0:
+ if len(arrInt) == 1:
+ nSum = nSum + arrInt[0]
+ del arrInt[0]
+ else:
+ nSum = nSum + int(str(arrInt[0]) + str(arrInt[-1]))
+ del arrInt[-1]
+ del arrInt[0]
+
+print (nSum)
+