Tennis Doubles

Tennis Doubles

Four friends have agreed to play doubles tennis. Each of the friends has a level of play, which is represented by a positive integer: the higher the number, the better the player's level.

The four friends want to form pairs to start the game. To make the game more interesting, they want the levels of the two teams to be as close as possible. The level of a team is the sum of the levels of the players on the team.

Although they are very good tennis players, the four friends are not very good at some other things, such as logic or mathematics. Can you help them and find the smallest possible difference between the levels of the teams that can be formed?

Input: Unsorted list of four integers (int).

Output: Integer.

Examples:

assert level_dif([1, 2, 3, 4]) == 0
assert level_dif([5, 5, 5, 5]) == 0
assert level_dif([1, 9, 3, 2]) == 5