Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Lists in mathematica

  1. Jan 12, 2010 #1

    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!
  2. jcsd
  3. Jan 14, 2010 #2
    Any thoughts?
  4. Jan 17, 2010 #3


    Staff: Mentor

    I didn't understand your problem description. I get that you want to use lists, but not what you want to do with them.
  5. Jan 17, 2010 #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:

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

    Thanks again!
  6. Jan 17, 2010 #5


    Staff: Mentor

    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]},
    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]]]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook