All problems
Trimmed Mean with Fixed Count
Problem
A symmetric trimmed mean with fixed count k removes the k smallest and k largest values, then averages the rest.
Given the values and k (with 2k < n), return the trimmed mean.
Hint
Sort first, then slice off both tails.
Test cases
case 1
in: [[1,2,3,4,5],1]
expected: 3
case 2
in: [[1,2,3,100],1]
expected: 2.5
case 3
in: [[0,10],0]
expected: 5
Starter codePython
def trimmed_mean_with_fixed_count(values, k):
# Your code here
pass3 test cases · run your code against them in the editor