# Assigning students in groups

I have a project with 60 students and 6 teachers. I'd like to know if it is possible to use Matrix and Permutation functions in Sage to assign those 60 students in 6 groups. There would be 6 sessions (a month each). Each student has to work once with each teacher and avoid being in the same group of students (as much as possible).

Thank you.

edit retag close merge delete

Sort by » oldest newest most voted

Here's a way to shuffle students into groups in python. It's not a solution to the problem you've posed, but it's a start.

from random import shuffle
a=['a','b','c','d','e','f','g','h','i','j','k','l']
n=len(a)/6
shuffle(a)
results=[[a[i] for i in range(j*6,j*6+6)] for j in range(0,n)]
results

more

Thank you for the answer. I think I could use this to fill 6 groups randomly with the 60 students. Since the numbers of students in each group is larger than the number of groups, the problem is difficult to solve (cf. social golfer problem). In my case, between two sessions, each teacher could, one after the other, use this program to generate the composition of his new group (10 new students among 60-10n students he never had yet, n being the session's number).

from random import shuffle
a=[[i] for i in range(60)]
n=len(a)/10
shuffle(a)
results=[[a[i] for i in range(j*10,j*10+10)] for j in range(0,n)]
results

more