In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 23rd
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #06 exercise sheet]


In this problem you should submit a function as described. Inside the function do not print anything that was not asked!

[IP057] A Summing Project

Marge Simpson, ever the supportive sister, has been watching Patty and Selma dive into the world of data manipulation with their matrix projects. She’s impressed by how they turned the chaotic hart into a simplified list and then back into a matrix, appreciating the complexity behind what seemed like simple tasks. Inspired by their enthusiasm and recognizing the potential for fun, Marge decides it’s time to try her hand at something a little more challenging herself: summing two matrices!

The Problem

Write a function sum(a, b) that given two matrices a and b (given as lists of lists), both with r rows and c columns, returns a new matrix c which is the result of summing a and b. This matrix should also have r rows and c columns and ci,j should be equal to summing ai,j with bi,j.

Constraints

The following limits are guaranteed in all the test cases that will be given to your program:

1 ≤ r, c ≤ 100       Number of rows and columns

Example Function Calls Example Output
print(sum([[1,2,3],[4,5,6],[7,8,9]],
          [[1,2,3],[4,4,4],[9,8,7]]))
print(sum([[9,8,7,6,5],[4,3,2,1,0]],
          [[2,4,6,8,10],[12,14,16,18,20]]))
[[2, 4, 6], [8, 9, 10], [16, 16, 16]]
[[11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto