β back to unit
Medium
# sorting medium
Fair Teams of Two
Pair the strongest player with the weakest, second strongest with second weakest β that's how you make fair teams. π€Ό
You get an EVEN number of skills. Sort, then pair the ends inward. Print each pair's total, in that order, separated by spaces.
Example:
Input: skills = [1, 9, 3, 7]
Output: 10 10
Sorted, the list becomes [1, 3, 7, 9]. Pairing the ends inward gives 1 + 9 = 10 and 3 + 7 = 10.
π‘ need a hint?
sort-fair-teams-of-two.pyπ given lines are locked β write your code in between
loading...