aboutsummaryrefslogtreecommitdiff
path: root/challenge-248/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
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)