good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: [OT] simple algorithm for assigning students to class sectionsby exussum0 (Vicar) |
on Nov 30, 2004 at 14:19 UTC ( [id://411190]=note: print w/replies, xml ) | Need Help?? |
Simpelest and most complex running time solution, create a graph of all students and create vertexes of which ones should not be in the same section. Then try and colour the graph as best you can. If you try to colour the graph by descending order of the degree of their vertexes, you'll get a smaller amount of colours. Each colour represents a section. This method doesn't give the uber best results. There are other graph colouring schemes to produce the optimal number.
Update: as for limiting the amount of people with the same class/colour, you can do that progrematically. Once a colour is all used up, use a new one by force.
----
In Section
Seekers of Perl Wisdom
|
|