All problems
Row Sums
Problem
Compute the vector of row sums of matrix A: entry i of the result is the sum of row i.
Hint
A row sum is a dot product with the all-ones vector.
Test cases
case 1
in: [[[1,2],[3,4]]]
expected: [3,7]
case 2
in: [[[1,-1],[0,0]]]
expected: [0,0]
case 3
in: [[[1,2,3]]]
expected: [6]
case 4
in: [[[1.5,2.5],[0.5,-1.5]]]
expected: [4,-1]
Starter codePython
def row_sums(A):
# Your code here
pass4 test cases · run your code against them in the editor