I have an interesting problem that others mot likely have run into at one point. I will be doing this in Java and figuring out the code, but first I need to figure out the best algorithm (or AN algorithm).
I have several groups (g1, g2, g3, g4, g5, ...). Each group has a set of members (so call them s1, s2, s3, s4, s5, ... respectively). Members are not limited to one group, so a member of group 1 could be a member of group 2 and/or 3 and/or ...
I am trying to find the minimum number of members so that all groups are represented. The obvious solution is to take one member from each group, but that is not necessarily the minimum number. The optimal solution, which will work only a small fraction of the time, is to do s1.retainsAll(s2).retainAll(s3).retainAll(s4).retainAll(s5)... but there is a high probability this will yield the empty set.
I could examine two sets, and then examine a third, etc. But who knows what order would be the best to do this.
This reminds me sort of of a least common multiple problem, but it does not really translate so well (unless there is some math genius who can tell me how to translate it ;-) ).
Has anyone else had to solve this? Can you offer any suggestions?