Random, roughly even distribution of items into sets? Let's say we have an unknown number of kids who will come to compete at a quiz game. Each kid has a known overall strength rating, as well as one of four areas of focus (let's say, math, English, science or music). Teams are ideally of the fixed size four and include one individual of each area of focus, though we would never have a team of one person and we'll never turn away someone. Instead, we'd prefer to have multiple teams of three.
Can anyone help give me ideas for a strategy to achieve this? Some thoughts that haven't been fully flushed out:


*

*Establish the number of teams and number of people per team

*Create a random grouping with no regard to any of our desired outcome. AFTER the groupings are created, evaluate their evenness with a score. Repeat this process x times and choose the grouping that has the best score.


Alternatively, perhaps I could instead think at a more micro level when I build each team about what I need. But I would like help flushing out this idea if it seems like a reasonable one. Specifically, how to account for the team's overall score as I pick from available players, as well as how to account for remaining options (or lack thereof) for future picking rounds. Maybe I don't need to consider boxing myself into a corner, but need to reserve the option to reverse course on a previous placement.
Any thoughts would be welcome!
 A: Here's my idea. 
Establish the number of teams and number of people per team. Given $n$ kids where $n \gt 5$, it is always possible to divide the kids into teams with either $3$ or $4$ members. Number the teams, starting with $1$ for the first $3$-member team (if it exists), $2$ for the second $3$-member team (if it exists), etc and moving onto the $4$-member teams when no more $3$-member teams exist.
Create $4$ arrays, one for each focus area, and place the kids in the relevant array. Sort each array so kids with the largest overall strength are on top. 
Starting with team $1$:


*

*Find the kid with the largest overall strength (among the $4$ arrays) who has a focus area which is not yet included in the team. Allocate this kid to the team and remove the kid from the array. (In the beginning all teams are empty, so in effect the kids are allocated only according to overall strength).

*Determine the next team. The next team will be the team with team number $1$ higher than the previous, until the last team. When a kid has been allocated to the last team, we go backwards toward team $1$. The next team after the last team will thus be the last team again, followed by the next-to-last team, followed by the next-to-next-to-last team, etc. The allocation thus works like a sprinkler, going back and forth across the teams.

*Go to 1, until there are no more kids.
This method should even out the overall strength for each team and also divide the focus areas evenly. 
Let me know what you think.
