It is a simple algorithm you can use for sport matches.
changes from previous version:
1- player capacity: from 6 to infinity
2- 20 lines less code
3- 5 less definitions
future changes:
1- uneven number of matches
2- set score criteria
It chooses the most competitive of all team possibilities:
First we get the information of all the players. Then we find the match with the least difference between the two teams out of all team possibilities.