Random partner (n=10), no repeats.
4 次查看(过去 30 天)
显示 更早的评论
I've been tasked with completing an activity where there are a total of 10 students in my class. I must be a partner with each student once for every homework assignment given. That being said, no two students are allowed to have repeat partners.
Are there any equations I can use in MATLAB to create this selection? I'm new to MATLAB and a bit unfamiliar on how I would go about this.
Thanks!
1 个评论
John D'Errico
2016-8-31
No. there are no "equations" to do this specific task. Anyway, asking for an equation to accomplish some programming task is meaningless. In fact, this is not a question about MATLAB at all, at least not at this point. And once you read the link I've given you below, the entire table is trivial to write down using paper, so again, no MATLAB content is involved.
I'd recommend that you do some reading. The place to look is under round-robin tournaments.
https://en.wikipedia.org/wiki/Round-robin_tournament
Read the section under scheduling algorithms. In fact, that is sufficient to write down the complete set of pairings using only pencil and paper.
采纳的回答
John D'Errico
2016-8-31
编辑:John D'Errico
2016-8-31
Easy peasy, and very possible, as long as you stop after 9 rounds of problems.
Using pencil and paper. As I said, this is a round robin tournament. Fix student 1 in position. Then starting with the configuration in the first round, just rotate the students in a clockwise fashion.
Round 1:
1 2 3 4 5
10 9 8 7 6
Round 2:
1 10 2 3 4
5 6 7 8 9
Round 3:
1 5 10 2 3
6 7 8 9 4
Round 4:
1 6 5 10 2
7 8 9 4 3
Round 5:
1 7 6 5 10
8 9 4 3 2
Round 6:
1 8 7 6 5
9 4 3 2 10
Round 7:
1 9 8 7 6
4 3 2 10 5
Round 8:
1 4 9 8 7
3 2 10 5 6
Round 9:
1 3 4 9 8
2 10 5 6 7
In each "round" just pair the students in any given column. There are no repeats after 9 rounds. So, in round 1, student 1 pairs with student 10, 2 pairs with 9, etc.
If you prefer, you can write this in the form of a 9x10 array. However, I will NOT do your homework for you. If you want to do this in MATLAB, you need to write code to do exactly what I just did. But that part is easy, IF you make the effort. I've done all the work for you.
更多回答(2 个)
Walter Roberson
2016-8-31
No, in general this problem is impossible, because no upper bound is given on the number of homework assignments, and after 9 homework assignments each student would have run out of "unused" students to do homework with.
Image Analyst
2016-8-31
Why can't you just do
numberOfHomeworkAssignments = 9;
iWorkWith = randperm(numberOfHomeworkAssignments)
Results:
iWorkWith =
7 5 4 3 6 9 2 8 1
This gives the student ID# that you're supposed to work with for that homework assignment.
So, on homework assignment #1, you work with student #7.
On homework assignment #2, you work with student #5.
On homework assignment #3, you work with student #4.
On homework assignment #4, you work with student #3.
and so on. You never will work with the same student on more than 1 assignment.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!