Generating Lists in Mathematica - Solve Student Partnering Problem

  • Mathematica
  • Thread starter sambroni
  • Start date
  • Tags
    Mathematica
In summary, the problem is that there are only 190 possible pairs, and you have to use 110 of them. However, you have a very strong constraint that in each group of 10 pairs you must use each person exactly once.
  • #1
sambroni
3
0
Hi-

I TA two lab sections, for which I need to have different partners for every student throughout the term. It's sort of a headache to do this by hand and it seemed like the Mathematica list function should be able to do this in a snap; but I'm having trouble writing the rules and syntax I need. I've been able to generate the lists via:
Table[Thread[{Table[i, {i, 16}],
Table[Mod[j + k, 16] + 1, {j, 16}]}], {k, 0, 10}]
but have had trouble winnowing down the lists.

Any help on this problem would be very appreciated. Thanks!
 
Physics news on Phys.org
  • #2
Any thoughts?
 
  • #3
I didn't understand your problem description. I get that you want to use lists, but not what you want to do with them.
 
  • #4
Thanks for your response.

The issue is that I need to pair up students each week (2 per group) from a class of 20. I have 11 weeks, and no two students may be in the same pair over the course of the semester. So I need to generate eleven lists of ten pairs such that 1-20 are paired up each week, and that no pairs are repeated.

e.g., week 1 could look like:
{{1,2},{3,4},{5,6},{7,8},{9,10},{11,12},{13,14},{15,16},{17,18},{19,20}}

and week 2 (up to week 11) couldn't reuse those pairs.

Thanks again!
 
  • #5
I am not sure that there is a solution to this problem. There are only 190 possible pairs, and you have to use 110 of them. However, you have a very strong constraint that in each group of 10 pairs you must use each person exactly once. This severely constrains the number of possible combinations. I tried a few hundred thousand random permutations and didn't get a single successful one.

nStudents = 20;
nWeeks = 11;

lst = Table[
tmp = With[{pairs = KSubsets[Range[nStudents], 2]},
Take[Partition[
Permute[pairs, rnd = RandomPermutation[Length[pairs]]],
nStudents/2], nWeeks]]; {Table[nStudents, {nWeeks}] ==
Map[Length, Map[Union, Flatten[tmp, {{1}, {2, 3}}]]],
rnd}, {100000}];
Union[lst[[All, 1]]]
 

1. How do I generate a list in Mathematica?

To generate a list in Mathematica, you can use the Table function, which allows you to specify the elements and the length of the list. For example, Table[i, {i, 1, 10}] will generate a list with elements from 1 to 10.

2. What is the difference between Table and Range in Mathematica?

Both Table and Range are functions used to generate lists in Mathematica. The main difference is that Table allows for more flexibility in specifying the elements and length of the list, while Range only generates a list with evenly spaced elements.

3. How can I solve a student partnering problem using Mathematica?

To solve a student partnering problem in Mathematica, you can use the Permutations function to generate all possible combinations of students, and then use Select to filter out the combinations that do not meet the given criteria (e.g. each student must have a different partner).

4. Can I use Mathematica to generate random lists?

Yes, Mathematica has several functions that can be used to generate random lists, such as RandomInteger, RandomReal, and RandomChoice. These functions allow you to specify the length and range of the list, as well as any specific distribution you want the elements to follow.

5. How can I manipulate and edit generated lists in Mathematica?

Mathematica has a wide range of functions that can be used to manipulate and edit lists. Some commonly used ones include Select, Map, Sort, and Part. These functions allow you to filter, transform, sort, and extract specific elements from a list, respectively.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
979
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
9
Views
943
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
Back
Top