7 kyu
The mean of two means
922 of 1,685smarthutza
Description:
Write a function that takes as parameters an array (arr) and 2 integers (x and y). The function should return the mean between the mean of the the first x elements of the array and the mean of the last y elements of the array.
The mean should be computed if both x and y have values higher than 1 but less or equal to the array's length. Otherwise the function should return -1.
Examples
[1, 3, 2, 4], 2, 3 => should return 2.5
because: the mean of the the first 2 elements of the array is (1+3)/2=2 and the mean of the last 3 elements of the array is (4+2+3)/3=3 so the mean of those 2 means is (2+3)/2=2.5.
[1, 3, 2, 4], 1, 2 => should return -1
because x is not higher than 1.
[1, 3, 2, 4], 2, 8 => should return -1
because 8 is higher than the array's length.
Arrays
Fundamentals
Similar Kata:
Stats:
Created | Nov 29, 2016 |
Published | Nov 29, 2016 |
Warriors Trained | 2735 |
Total Skips | 33 |
Total Code Submissions | 6978 |
Total Times Completed | 1685 |
JavaScript Completions | 724 |
Crystal Completions | 10 |
Python Completions | 922 |
Ruby Completions | 94 |
Total Stars | 29 |
% of votes with a positive feedback rating | 90% of 385 |
Total "Very Satisfied" Votes | 319 |
Total "Somewhat Satisfied" Votes | 52 |
Total "Not Satisfied" Votes | 14 |
Total Rank Assessments | 12 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |