how to write a method that accepts two square matrices (nxn two dimensional arrays), and return the sum of the two. Both matrices being passed into the method will be of size nxn (square), containing only integers.
How to sum two matrices: Take each cell [n][m] from the first matrix, and add it with the [n][m] cell from the second matrix. This will be cell [n][m] in the solution matrix.
like:
|1 2 3|
|3 2 1|
|1 1 1|
+
|2 2 1|
|3 2 3|
|1 1 3|
=
|3 4 4|
|6 4 4|
|2 2 4|
matrix_addition( [ [1, 2, 3], [3, 2, 1,], [1, 1, 1] ], [ [2, 2, 1], [3, 2, 3], [1, 1, 3] ] )
returns [ [3, 4, 4], [6, 4, 4], [2, 2, 4] ]