#30 - Matrix Addition and Subtraction

You are given two matrices of the same size, each containing integer values. Your task is to implement functions to perform addition and subtraction of these matrices.

Example

Input

A = [
    [1,2,3],
    [4,5,6],
    [7,8,9]
]

B = [
    [9,8,7],
    [6,5,4],
    [3,2,1]
]

Output

addition

[
    [10, 10, 10],
    [10, 10, 10],
    [10, 10, 10]
]

subtraction 

[ 
    [-8, -6, -4],
    [-2,  0,  2],
    [ 4,  6,  8]
]

Last updated