Splitting into two teams
Write code · Challenge · §7.2 Permutations and combinations
A game streamer is holding an event for viewers. skills holds the skill of each participant, and the participants are split into two teams with the same number of people. A team's score is the sum of its members' skills.
Complete the function solution, which returns the smallest possible difference between the scores of the two teams (the higher score minus the lower score).
Function
solution(skills)
Constraints
- The length of
skillsis an even number from 2 to 16. - Each skill is an integer from 1 to 1,000.
Examples
| skills | result |
|---|---|
[1, 2, 3, 4] | 0 |
[4, 7, 1, 9, 2, 6] | 1 |
Starter code
def solution(skills):
answer = 0
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.