Quote:
Originally posted by bmacri
Well I couldn't come up with much else. At least I thought this was some what humorous. Oh well. I do have an interesting coding question. It's long and not quite on the topic so if someone else wants to ask a better question that fine. But here goes.
My boss goes on a golfing trip every year with about a dozen friends. They play usually seven rounds of golf over a few days. At the beginning of each round they form into groups for that round. If possible they want to play with people they haven't played with before or at least not that much with. One thought was to write a program that came up with the pairings based on a few rules. Most of this has been coded but one piece is missing. How can we get all the possible ways of pairing the people up without any duplication? Here's an example of what I mean.
We have 12 people and want to form groups of 4. An array of
1,2,3,4,5,6,7,8,9,10,11,12 means person 1,2,3,4 play in one group, 5,6,7,8 play in another and 9,10,11,12 play in the last. The next round could look like 1,2,5,10,3,4,6,11,7,8,9,12 which means 1,2,5,10 play in the first group, 3,4,6,11 play in the next and 7,8,9,12 play in the last.
We have ways of evaluating each round and finding the best combination to use for that round. The problem is coming up with all possible combinations for that round WITHOUT duplicates. Does anyone have code or thoughts on how to do this? The kicker is everything needs to be variable. There may be 14 people instead of 12. The groups might be 3 people instead of 4. So nothing can be hard coded.
Any help would be great.
-Ben
I've not given this much thought but one brutal way of doing it would be to do a genetic search. Each round try a bunch of random groupings and evaluate the fitness of each one by penalizing combinations that include players who have played before. Then continue with the genetic search until you have come up with some good pairings at each level. It wouldn't be too hard to code this or use someones existing code. It would also be fairly easy to make it work for different sample and grouping sizes.