Given an array collection:
[ [1,2,3,4], [2,3,4,5], [3,4,5,6] ]
Return an array with the average of the columns:
[2,3,4,5]
While basic, you may find an interesting feature of Ruby.
Bonus
That same solution has to work for:
[[1,2,3,4]]
I'll post my solution some time later tomorrow, unless a lot of replies come in tonight.
Problem Sets
10 x 10
[ [99, 47, 80, 22, 83, 45, 4, 4, 59, 65], [13, 24, 50, 86, 6, 72, 83, 46, 94, 96], [75, 73, 0, 56, 7, 50, 56, 49, 7, 56], [78, 28, 6, 44, 63, 0, 88, 88, 67, 45], [63, 70, 2, 7, 7, 71, 91, 66, 4, 78], [96, 38, 46, 90, 40, 50, 94, 53, 45, 31], [24, 37, 53, 19, 94, 11, 82, 12, 96, 84], [94, 7, 10, 71, 44, 15, 42, 72, 54, 95], [3, 13, 32, 30, 53, 58, 63, 76, 50, 11], [75, 8, 97, 68, 27, 4, 67, 98, 64, 1] ]
Solution:
[62, 34, 37, 49, 42, 37, 67, 56, 54, 56]
This post has been edited by Lemur: 27 January 2014 - 09:25 PM

New Topic/Question
Reply


MultiQuote




|