aboutsummaryrefslogtreecommitdiff
path: root/challenge-248/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2023-12-18 15:26:15 -0500
committerDave Jacoby <jacoby.david@gmail.com>2023-12-18 15:26:15 -0500
commitf20e269818207c1e25f7c53100ee170beaa780a6 (patch)
tree825564a39e4ed63bbab64dbc68f37ad414dedc64 /challenge-248/eric-cheung/python/ch-2.py
parent908aa39a6d95d19cbe8f59dc56918676ccca5976 (diff)
parent6dfa3483d23541833b24e099be6695a90445813c (diff)
downloadperlweeklychallenge-club-f20e269818207c1e25f7c53100ee170beaa780a6.tar.gz
perlweeklychallenge-club-f20e269818207c1e25f7c53100ee170beaa780a6.tar.bz2
perlweeklychallenge-club-f20e269818207c1e25f7c53100ee170beaa780a6.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-248/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-248/eric-cheung/python/ch-2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-248/eric-cheung/python/ch-2.py b/challenge-248/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..61e8e84fd1
--- /dev/null
+++ b/challenge-248/eric-cheung/python/ch-2.py
@@ -0,0 +1,13 @@
+
+## arrMatrixInput = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] ## Example 1
+arrMatrixInput = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]] ## Example 2
+
+arrMatrixOutput = []
+
+for nRow in range(len(arrMatrixInput) - 1):
+ arrRow = []
+ for nCol in range(len(arrMatrixInput[nRow]) - 1):
+ arrRow.append(arrMatrixInput[nRow][nCol] + arrMatrixInput[nRow][nCol + 1] + arrMatrixInput[nRow + 1][nCol] + arrMatrixInput[nRow + 1][nCol + 1])
+ arrMatrixOutput.append(arrRow)
+
+print (arrMatrixOutput)