You may also want to visit some other constraints and "pathalogical cases". e.g. Is it important that sections have the approximately the same size? If so, is giving a student his or her first choice more or less important than keeping sizes similar? What if everyone prefers section 1 as a first choice, 2 as a second, etc? Is the aforementioned lottery "fair" or, as is noted below, are there other criteria applied to give particular students' choices greater weight?
Just some thoughts to get you started tinking...