Given a collection of
struct Person {
string name;
int team;
bool swimmer;
};
vector<Person> people;
is there a "well known" algorithm to distribute them into the least number of fixed-size bins with the following conditions:
- No two people in the same bin can be from the same team
- At least one person in each bin must be a swimmer
I'm looking for a solution with the smallest number of bins required to accommodate every Person. The bins do not have to be fully filled.
If half are swimmers and the bin size is four, the easiest solution is to put one swimmer with one non-swimmer. However, the most efficient solution is to put two swimmers and two non-swimmers in a bin (team membership permitting).
The number of different teams can be greater than the size of a bin, so there would be many solutions.
Obviously, if people.size() / bin_size > number of swimmers, there would be no solution.