ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 04 Mar 2013 22:48:09 +0100Assigning students in groupshttps://ask.sagemath.org/question/9871/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.Sun, 03 Mar 2013 18:03:06 +0100https://ask.sagemath.org/question/9871/assigning-students-in-groups/Answer by Kaiserfilk for <p>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).</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/9871/assigning-students-in-groups/?answer=14624#post-id-14624Thank 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
Mon, 04 Mar 2013 22:48:09 +0100https://ask.sagemath.org/question/9871/assigning-students-in-groups/?answer=14624#post-id-14624Answer by calc314 for <p>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).</p>
<p>Thank you.</p>
https://ask.sagemath.org/question/9871/assigning-students-in-groups/?answer=14623#post-id-14623Here'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
Mon, 04 Mar 2013 09:20:55 +0100https://ask.sagemath.org/question/9871/assigning-students-in-groups/?answer=14623#post-id-14623