Ctrl K

Judges' Score Without the Extremes

Easy
A performance was rated by several judges, and their scores are in the array scores. To keep overly harsh and overly generous judges from swaying the result, the lowest 5% and the highest 5% of scores are discarded (the number of judges is always a multiple of 20, so that is a whole number of scores on each side). Return the mean of the remaining scores, rounded to 5 decimal places.
Example 1
scores=[0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 100] → 7.0

There are 20 scores, so one is dropped from each end: 0 and 100. Eighteen 7s remain, and their mean is 7.

Example 2
scores=[5, 3, 9, 1, 4, 8, 2, 6, 7, 10, 5, 3, 9, 1, 4, 8, 2, 6, 7, 10] → 5.5

One 1 and one 10 are dropped. The other 18 scores add up to 99, so the mean is 5.5.

Example 3
scores=[4, 0, 9, 2, 2, 8, 5, 1, 7, 3, 6, 6, 0, 9, 4, 5, 3, 8, 1, 7, 2, 4, 6, 8, 10, 3, 5, 7, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] → 4.97222
Constraints
  • 20 ≤ len(scores) ≤ 1000
  • len(scores) is a multiple of 20
  • 0 ≤ scores[i] ≤ 10⁵
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsMerge Into the Spare Tail EasyThe Candidate With Most Votes EasyDoes Any Value Repeat EasyMake It to Every Meeting EasyThe Lost Ticket Easy
loading Python…
Input
scores=[0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 100]
Expected
7.0

Run checks the first 3 tests in your browser. Submit checks all 22 tests on the server, hidden ones included.