7 kyu
Moving Average
Description:
Background
Moving average of a set of values and a window size is a series of local averages.
Example:
Values: [1, 2, 3, 4, 5]
Window size: 3
Moving average is calculated as:
1, 2, 3, 4, 5
| |
^^^^^^^
(1+2+3)/3 = 2
1, 2, 3, 4, 5
| |
^^^^^^^
(2+3+4)/3 = 3
1, 2, 3, 4, 5
| |
^^^^^^^
(3+4+5)/3 = 4
Here, the moving average would be [2, 3, 4]
Task
Given a list values
of integers and an integer n
representing size of the window, calculate and return the moving average.
When integer n
is equal to zero or the size of values
list is less than window's size, return None
Reference: Moving average
Algorithms
Logic
Mathematics
Lists
Similar Kata:
Stats:
Created | Feb 25, 2019 |
Published | Feb 25, 2019 |
Warriors Trained | 1501 |
Total Skips | 11 |
Total Code Submissions | 4367 |
Total Times Completed | 831 |
Python Completions | 831 |
Total Stars | 22 |
% of votes with a positive feedback rating | 92% of 193 |
Total "Very Satisfied" Votes | 168 |
Total "Somewhat Satisfied" Votes | 21 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 33 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |