aboutsummaryrefslogtreecommitdiff
path: root/challenge-337/eric-cheung/python
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-09-01 20:26:10 +0100
committerMohammad Sajid Anwar <mohammad.anwar@yahoo.com>2025-09-01 20:26:10 +0100
commit598b053a884d608580077ec5985f8446f5a9a836 (patch)
tree40634712faf2d30c61689ea769da7b3fce419849 /challenge-337/eric-cheung/python
parent167fa7566630b177f499ddd63cfb2290cd665ef5 (diff)
downloadperlweeklychallenge-club-598b053a884d608580077ec5985f8446f5a9a836.tar.gz
perlweeklychallenge-club-598b053a884d608580077ec5985f8446f5a9a836.tar.bz2
perlweeklychallenge-club-598b053a884d608580077ec5985f8446f5a9a836.zip
- Added solutions by Peter Meszaros.
- Added solutions by Peter Campbell Smith. - Added solutions by Simon Proctor. - Added solutions by Benjamin Andre. - Added solutions by Thomas Kohler. - Added solutions by David Ferrone. - Added solutions by Eric Cheung. - Added solutions by Ulrich Rieke.
Diffstat (limited to 'challenge-337/eric-cheung/python')
-rwxr-xr-xchallenge-337/eric-cheung/python/ch-1.py10
-rwxr-xr-xchallenge-337/eric-cheung/python/ch-2.py41
2 files changed, 51 insertions, 0 deletions
diff --git a/challenge-337/eric-cheung/python/ch-1.py b/challenge-337/eric-cheung/python/ch-1.py
new file mode 100755
index 0000000000..4895bc0459
--- /dev/null
+++ b/challenge-337/eric-cheung/python/ch-1.py
@@ -0,0 +1,10 @@
+
+## arrNum = [6, 5, 4, 8] ## Example 1
+## arrNum = [7, 7, 7, 7] ## Example 2
+## arrNum = [5, 4, 3, 2, 1] ## Example 3
+## arrNum = [-1, 0, 3, -2, 1] ## Example 4
+arrNum = [0, 1, 1, 2, 0] ## Example 5
+
+arrOutput = [len([nSubElem for nSubElem in arrNum if nElem > nSubElem]) for nElem in arrNum]
+
+print (arrOutput)
diff --git a/challenge-337/eric-cheung/python/ch-2.py b/challenge-337/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..c6ec551a39
--- /dev/null
+++ b/challenge-337/eric-cheung/python/ch-2.py
@@ -0,0 +1,41 @@
+
+## Example 1
+## nRow = 2
+## nCol = 3
+## arrLoc = [[0, 1], [1, 1]]
+
+## Example 2
+## nRow = 2
+## nCol = 2
+## arrLoc = [[1, 1], [0, 0]]
+
+## Example 3
+## nRow = 3
+## nCol = 3
+## arrLoc = [[0, 0], [1, 2], [2, 1]]
+
+## Example 4
+## nRow = 1
+## nCol = 5
+## arrLoc = [[0, 2], [0, 4]]
+
+## Example 5
+nRow = 4
+nCol = 2
+arrLoc = [[1, 0], [3, 1], [2, 0], [0, 1]]
+
+arrList = [[0 for _ in range(nCol)] for _ in range(nRow)]
+
+for arrLoop in arrLoc:
+ nRowIndx = arrLoop[0]
+ nColIndx = arrLoop[1]
+
+ for nIndx in range(nCol):
+ arrList[nRowIndx][nIndx] = arrList[nRowIndx][nIndx] + 1
+
+ for nIndx in range(nRow):
+ arrList[nIndx][nColIndx] = arrList[nIndx][nColIndx] + 1
+
+nOddCount = sum([len([nElem for nElem in arrLoop if nElem % 2 == 1]) for arrLoop in arrList])
+
+print (nOddCount)