aboutsummaryrefslogtreecommitdiff
path: root/challenge-252/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-16 20:21:31 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2024-01-16 20:21:31 +0000
commit857d573334deaa24866cb695f1e3758a85c0b9d9 (patch)
tree357858672feabff853babfbb96035d61b4b688e0 /challenge-252/eric-cheung/python
parent47becd4d92af268e02cd61bb2b77816a4c8ed06b (diff)
downloadperlweeklychallenge-club-857d573334deaa24866cb695f1e3758a85c0b9d9.tar.gz
perlweeklychallenge-club-857d573334deaa24866cb695f1e3758a85c0b9d9.tar.bz2
perlweeklychallenge-club-857d573334deaa24866cb695f1e3758a85c0b9d9.zip
- Added solutions by Eric Cheung.
- Added solutions by Ulrich Rieke. - Added solutions by Laurent Rosenfeld. - Added solutions by PokGoPun. - Added solutions by Simon Proctor. - Added solutions by Niels van Dijke. - Added solutions by Mark Anderson. - Added solutions by E. Choroba. - Added solutions by Cheok-Yin Fung. - Added solutions by Peter Campbell Smith. - Added solutions by W. Luis Mochan. - Added solutions by Peter Meszaros. - Added solutions by Thomas Kohler. - Added solutions by David Ferrone. - Added solutions by Luca Ferrari. - Added solutions by Roger Bell_West. - Added solutions by Steven Wilson. - Added solutions by Matthew Neleigh. - Added solutions by Paulo Custodio.
Diffstat (limited to 'challenge-252/eric-cheung/python')
-rwxr-xr-xchallenge-252/eric-cheung/python/ch-1.py6
-rwxr-xr-xchallenge-252/eric-cheung/python/ch-2.py10
2 files changed, 16 insertions, 0 deletions
diff --git a/challenge-252/eric-cheung/python/ch-1.py b/challenge-252/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..73003ac315
--- /dev/null
+++ b/challenge-252/eric-cheung/python/ch-1.py
@@ -0,0 +1,6 @@
+
+## arrInt = [1, 2, 3, 4] ## Example 1
+arrInt = [2, 7, 1, 19, 18, 3] ## Example 2
+
+arrOutput = [arrInt[nIndx] * arrInt[nIndx] for nIndx in range(len(arrInt)) if len(arrInt) % (nIndx + 1) == 0]
+print (sum(arrOutput))
diff --git a/challenge-252/eric-cheung/python/ch-2.py b/challenge-252/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..e943434336
--- /dev/null
+++ b/challenge-252/eric-cheung/python/ch-2.py
@@ -0,0 +1,10 @@
+
+## nInput = 5 ## Example 1
+## nInput = 3 ## Example 2
+## nInput = 1 ## Example 3
+nInput = 4 ## Example 4
+
+nMax = int(nInput / 2 if nInput % 2 == 0 else (nInput - 1) / 2)
+arrOutput = [nLoop for nLoop in range(-nMax, nMax + 1) if nLoop != 0 or nInput % 2 == 1]
+
+print (arrOutput)