← back to unit
Medium
# sorting medium
The Fair Middle
An even number of kids — no single middle! The referee weight is the average of the two middle kids (it always comes out whole here). ⚖️
You get an EVEN number of weights. Sort, take the two middle values, and print their average.
Example:
Input: weights = [10, 30, 20, 40]
Output: 25
Sorted, the list becomes [10, 20, 30, 40] — the two middle values are 20 and 30, averaging to 25.
💡 need a hint?
sort-fair-middle.py🔒 given lines are locked — write your code in between
loading...