Our society is dependent upon the stable selection of pairs. Whether it’s in marriage, roommate selection in college, or even a doctor choosing their residency; each represents a group with preferences looking to pair with another group with preferences. But what is the best way to go about pairing these groups?

The Stable Marriage Problem, for which the nobel prize in economics was awarded in 2012, is an algorithm that answers this question. In these pairings, there has long been the issue of an “unstable marriage,” a pairing in which one person in that pairing would be happier with someone else who is already married, and they would prefer them as well, an issue all too common in algorithms that were popular before. In this scenario, happiness is wasted because of the ineffective algorithm. The end result of the Stable Marriage Problem is a complete lack of these unstable marriages and the minimization of total unhappiness.

These two groups with very different preferences need to be matched, how would you do it?