30
1
Given a nonempty list of nonempty rows of numbers, compute the column wise sum, which is another list that has the length of the longest input row. The first entry of the output list is the sum of all the first entires of the input rows, the second one is the sum of all the second elements (if available) etc. I think following example will explain it way better:
Input: {[1,2,3,4],[1],[5,2,3],[6,1]}
Computation: [1,2,3,4]
+ . . .
[1]. . .
+ + + .
[5,2,3].
+ + . .
[6,1]. .
= = = =
Output: [13,5,6,4]
Test Cases
{[0]} -> 0
{[1],[1,1,1,1]} -> [2,1,1,1]
{[1],[1,2],[1,2,3],[1,2,3,4]} -> [4,6,6,4]
{[1,6,2,-6],[-1,2,3,5]} -> [0,8,5,-1]
Will the arrays only contain integers? – ETHproductions – 2016-12-19T21:18:39.150
I did not think about that so far but I think you can assume that. Is there anything speaking against that? – flawr – 2016-12-19T21:40:34.493
I don't think so. All of your test cases use only integers, and I'm fairly certain it won't invalidate any existing answers (and may even save bytes for some answers). – ETHproductions – 2016-12-19T21:43:51.483
Well then I think that this assumption is perfectly acceptable. It also doesn't change the challenge itself. – flawr – 2016-12-19T21:53:54.687