"""
    Author:         CaptCorpMURICA
    Project:        pythonExercises
    File:           add.py
    Creation Date:  6/5/2019, 7:59 PM
    Description:    I'd like you to write a function that accepts two lists-of-lists of numbers and returns one
                    list-of-lists with each of the corresponding numbers in the two given lists-of-lists added together.

                    It should work something like this:

                    >>> matrix1 = [[1, -2], [-3, 4]]
                    >>> matrix2 = [[2, -1], [0, -1]]
                    >>> add(matrix1, matrix2)
                    [[3, -3], [-3, 3]]
                    >>> matrix1 = [[1, -2, 3], [-4, 5, -6], [7, -8, 9]]
                    >>> matrix2 = [[1, 1, 0], [1, -2, 3], [-2, 2, -2]]
                    >>> add(matrix1, matrix2)
                    [[2, -1, 3], [-3, 3, -3], [5, -6, 7]]

                    Try to solve this exercise without using any third-party libraries (without using pandas for
                    example).

                    Before attempting any bonuses, I'd like you to put some effort into figuring out the clearest and
                    most idiomatic way to solve this problem.

                    There are two bonuses this week.

                    For the first bonus, modify your add function to accept and "add" any number of lists-of-lists.

                    >>> add([[1, 9], [7, 3]], [[5, -4], [3, 3]], [[2, 3], [-3, 1]])
                    [[8, 8], [7, 7]]

                    For the second bonus, make sure your add function raises a ValueError if the given lists-of-lists
                    aren't all the same shape.

                    >>> add([[1, 9], [7, 3]], [[1, 2], [3]])
                    Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                    File "add.py", line 10, in add
                      raise ValueError("Given matrices are not the same size.")
                    ValueError: Given matrices are not the same size.

                    Automated tests for this week's exercise can be found here. You'll need to write your function in a
                    module named add.py next to the test file. To run the tests you'll run "python test_add.py" and
                    check the output for "OK". You'll see that there are some "expected failures" (or "unexpected
                    successes" maybe). If you'd like to do the bonus, you'll want to comment out the noted lines of code
                    in the tests file to test them properly.

                    You'll receive some answers and links to resources explaining ways to solve this exercise within a
                    few days. Don't peek at the answers before attempting to solve this on your own.
"""


def add(m1, m2):
    if len(m1) != len(m2):
        raise ValueError("Given matrices are not the same size.")
    for i in range(0, len(m1)):
        if len(m1[i]) != len(m2[i]):
            raise ValueError("Given matrices are not the same size.")
        for j in range(0, len(m1[0])):
            m1[i][j] = (m1[i][j] + m2[i][j])
    return m1


matrix1 = [[1, -2], [-3, 4]]
matrix2 = [[2, -1], [0, -1]]
add(matrix1, matrix2)
