← back to unit
Medium
# sorting medium
Trim the Judges' Scores
Olympic rules: toss the single highest and single lowest score, average the rest. 🤸
You get at least three scores (the trimmed average always comes out whole). Print it.
Example:
Input: scores = [6, 9, 4, 7, 9]
Output: 7
Sorted, the list becomes [4, 6, 7, 9, 9]. Trimming the lowest (4) and highest (9) leaves [6, 7, 9], which averages to 7.
💡 need a hint?
sort-trim-judges.py🔒 given lines are locked — write your code in between
loading...