pairing groups which will not repeat

Pairings groups which will not repeat


I teach and would like to pare students (21 students in total) into pairs of 2 students in each pairing. Each week the pairings will change so students are matched with another student. I do not want to repeat the same pairing for as long as I can delay that.


Does anyone know a "simple" or straightforward way to use Pages to keep track of those 2-person pairings and visibly show (to me) what the next pairings will be?


Thank you.

MacBook Pro (15-inch Mid 2010), Mac OS X (10.7.5), 2.53 GHz Intel Core i5, 4 GB 1067 MHz DDR3

Posted on Aug 21, 2016 6:06 AM

Reply
11 replies

Aug 21, 2016 9:32 AM in response to JayMiller3

This is a combinations (nCr) problem with 210 unique pairing outcomes. The following Python script will generate those unique name pairs and write them out to a text file.

#!/usr/bin/python

# coding: utf-8

# nCr combinations solution, read n choose r. Generate a unique list of combinations.

# In this example, we take 21 students as n, and r = 2 is the pair combinations.

# Usage: student_pairs.py names.txt > ~/Desktop/pairings.txt

# names.txt is the student names, one per line.

# output format: student name 1 : Student name 2


import fileinput

import itertools

import sys


student_list = []

# read in student list and append their names in a list without newlines

for line in fileinput.input(sys.argv[1:]):

student_list.append(line.strip())

# apply the nCr combinations formula to the student list as 21C2.

for namepair in itertools.combinations(student_list, 2):

print('{} : {}'.format(namepair[0], namepair[1]))

sys.exit()


Steps:

  1. Copy/paste the above script into TextEdit that already has Format menu : Make Plain Text set. Save as
    student_pairs.py (override TextEdit's insistence on .txt extension) to your Desktop.
  2. Open the Terminal application (Launchpad : Other : Terminal) Type only the blue text content below.

    # change directory to the Desktop

    $ cd ~/Desktop

    # make Python program executable

    $ chmod +x student_pairs.py

    # run the program with the student name list as input and produce the output file

    $ student_pairs.py names.txt > pairings.txt


At this point, you have your generated list of name pairs, and you can open and format this in Pages. Quit the Terminal.

Aug 21, 2016 10:01 AM in response to VikingOSX

Viking


I am trying to read your script.


Since this is a SUM of a series 0 to 21, zero being NoPartner, I determined there were 231 pairs and each week there would be 11 pairs (one being a student with no pair) that is 21 weeks to go through all the pairs.


As no student can be in 2 pairs simultaneously in the one week, I can not see how your script avoids this. It appears to generate a list of all possible pairs.


Have I missed something? 🙂


Peter

Aug 21, 2016 12:24 PM in response to PeterBreis0807

Peter,


This Python script does strictly produce a mathematical combination of paired students. That is 210 (unique) pairs in the output. For 21 students each gets 21 - 1 (20 pairings). No one appears to be unpaired.


Properly sorted in the Terminal

$ combo.py names.txt | sort -t' ' -nk2 -nk5 > ~/Desktop/pairs.txt


The above sorts individual student pairings numerically for better visual organization. If each student gets 20 unique pairings with another student, that would suggest that no pairing repetition should occur until week 21. The assumption is that pairings occur only once per week. The organization of those pairings can be taken from the generated pairing list, or by another organizational method.

Aug 21, 2016 1:28 PM in response to VikingOSX

I looked at this way:


1. With 21 students every week one student faces an empty chair, NonPartner (0) ie 21 + 1, making actually 11 pairs/week


2. Total unique pairs is 231 or 11 matches per week for 21 weeks.


3. The complete list of pairs needs to be secondary sorted into 11 sets of pairs where no student is in two pairs each week.


The third point was where I got bogged down. I could work out an algorithm, basically a sliding match up to week 11, then it became a progressive match upwards, always to a higher number with a check to see if there had been a previous match. That is where it got messy.


Peter


PS I can't be certain but my gut instinct says this is similar to a Sudoku solution where there is only one solution for the combinations of pairs over the 21 sets, but haven't got my head around how to write the sort other than a tedious working down, eliminating matches within sets one by one. I can eliminate the first 12 sets because they are progressions, its the last 9 that becomes a test by each case.

Aug 21, 2016 1:43 PM in response to VikingOSX

My initial idea of doing the sets by simple division and progression, looks like it may not resolve into complete sets over the entire 21 weeks.


The tough nut is meeting both the unique pairing AND every single student is paired in only one pair per week.


In practice, unless there was some reason to make every student partner with every other student without exception (not accounting for absences) I'd just run the exercise for the 12 easily sorted weeks and consider it a good mix.


Peter

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

pairing groups which will not repeat

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.