Sum of a matrix, even or odd

Posted by user1790201 on Stack Overflow See other posts from Stack Overflow or by user1790201
Published on 2012-11-23T04:22:35Z Indexed on 2012/11/23 4:59 UTC
Read the original article Hit count: 99

Filed under:

This function receives a numeric matrix represented as a list of rows, where each row is in turn a list. Assume that it is a square matrix: all rows have the same length and there are as many rows as elements in each row. Also assume that the matrix is at least of dimension 2 by 2 (i.e. minimally the matrix has 2 rows with 2 elements each) The function should return a list with as many elements as number of rows. Element i in the resulting list should have the sum of the values in row i.

For example, if the matrix is

1   2   3
10  20  30
100 200 300

then this function should return the list [6,60,600]

That is, addValuesInAllRows( [ [1,2,3], [10,20,30], [100,200,300] ] ) should return [6,60,600]

Isn't this sort of similar but how would you sum up the list individually

© Stack Overflow or respective owner

Related posts about python