[Solved] Sum of arrays of different size [closed]
[ad_1] You can use something like this: a.flat_map{|x| x.in_groups_of(a.max_by(&:size).size, 0)}.transpose.map(&:sum) Or this: a.max_by(&:size).map.with_index{|_, i| a.sum{|x| x[i]||0}} 4 [ad_2] solved Sum of arrays of different size [closed]