I’m trying to code a random team selection program. The inputs are a list of pairs and a list of singles. The output should be a random list of teams with either 3 or 4 members, minimizing the number of 3 man teams.

Given pairs = [(a,b), (c,d), (e,f), (g,h)]

and singles = [x, y, z]

then teams might be [ a, b, g, h]; [c, d, x, z] and [e, f, y]

while

Given pairs = [(a,b), (c,d), (e,f), (g,h), (i,j)]

and singles = [x, y, z]

then teams might be [ c, d, i, j]; [e, f ,y]; [a, b, x] and [i, j, z]

What I need is code to calculate the number of 4 man teams and the number of 3 man teams where the number of 3 man teams is minimized.

Thanks. If this topic is not allowed I will remove it.