I have a similar question to that of Stable Marriage Problem.

This is the criteria
1) 1 Student must have 1 Teacher only.
2) 1 Teacher ideally should have 3-4 Students.

The spreadsheet is done using Google Apps Script (Javascript). How do I go about with the system calculation and giving teachers the system-generated result (3-4 Students) ?

enter image description here

  • 2
    $\begingroup$ As you've noted, this is an instance of a standard problem. What have you tried towards applying standard solutions? Hint: get read of spreadsheet software. Export the data as CSV and learn a scripting language. Empower yourself! (Also, please clarify what and where the "ranking" you mention (only) in the title is.) $\endgroup$
    – Raphael
    Feb 3, 2016 at 11:56
  • $\begingroup$ Does this differ at all from the hospital/resident algorithm? nrmp.org/match-process/match-algorithm $\endgroup$
    – Dusty
    Feb 3, 2016 at 20:16
  • $\begingroup$ NRMP algorithm was developed because medical students could effectively rig their choices to get a favorable hospital assignment. But, if choices are given in a fair way, I think the stable marriage algorithm would give the right answer, as shown by Roth in 1984 (Roth, Alvin E. [1984], "The Evolution of the Labor Market for Medical Interns and Residents: A Case Study in Game Theory," Journal of Political Economy, 92, 91-1016). Then Roth reevaluated the algorithm in 1995. $\endgroup$ Feb 4, 2016 at 13:35

1 Answer 1


Your problem differs from stable marriage problem in a minor way. A teacher can have 4 students maximum. You will have to fix the maximum students allotted to teacher (you may not have 3-4, if you also prescribe minimum number of students then you might have to dig deeper).

Now you can do two things, first, have four copies of each teacher and solve the stable marriage problem. Second solution is essentially like first but you keep a list of 4 "engagements" for each teacher.

  • $\begingroup$ 2nd solution seems easier. I'm currently using the javascript method from rosettacode.org/wiki/Stable_marriage_problem However, how do I allow 4 engagements instead of just 1? $\endgroup$
    – chopz
    Feb 4, 2016 at 0:59
  • $\begingroup$ In stable marriage algorithm, a man proposes and then the woman is provisionally "engaged". There a man and woman can have only one "engagement". However, in this case a teacher can have four "engagements" where as a student can have only one, if I understand the problem properly. $\endgroup$ Feb 4, 2016 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.