7 kyu

Average Array

1,004 of 2,091K-Calderon-ASC

Description:

ASC Week 1 Challenge 5 (Medium #2)

Create a function that takes a 2D array as an input, and outputs another array that contains the average values for the numbers in the nested arrays at the corresponding indexes.

Note: the function should also work with negative numbers and floats.

Examples

[ [1, 2, 3, 4], [5, 6, 7, 8] ]  ==>  [3, 4, 5, 6]

1st array: [1, 2, 3, 4]
2nd array: [5, 6, 7, 8]
            |  |  |  |
            v  v  v  v
average:   [3, 4, 5, 6]

And another one:

[ [2, 3, 9, 10, 7], [12, 6, 89, 45, 3], [9, 12, 56, 10, 34], [67, 23, 1, 88, 34] ]  ==>  [22.5, 11, 38.75, 38.25, 19.5]

1st array: [  2,   3,    9,   10,    7]
2nd array: [ 12,   6,   89,   45,    3]
3rd array: [  9,  12,   56,   10,   34]
4th array: [ 67,  23,    1,   88,   34]
              |    |     |     |     |
              v    v     v     v     v
average:   [22.5, 11, 38.75, 38.25, 19.5]
Fundamentals

Stats:

CreatedJul 19, 2017
PublishedJul 20, 2017
Warriors Trained3812
Total Skips83
Total Code Submissions7601
Total Times Completed2091
JavaScript Completions1004
C# Completions197
Ruby Completions116
Haskell Completions53
Python Completions728
PHP Completions85
Total Stars47
% of votes with a positive feedback rating91% of 462
Total "Very Satisfied" Votes392
Total "Somewhat Satisfied" Votes58
Total "Not Satisfied" Votes11
Total Rank Assessments11
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • K-Calderon-ASC Avatar
  • anter69 Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • Souzooka Avatar
  • leesc22 Avatar
  • hobovsky Avatar
  • cliffstamp Avatar
  • user8436785 Avatar
  • saudiGuy Avatar
Ad