Skip to content

Instantly share code, notes, and snippets.

View jnawjux's full-sized avatar

John jnawjux

  • Seattle, WA
View GitHub Profile
@joyrexus
joyrexus / README.md
Last active February 12, 2024 19:59
The Stable Marriage Problem

My implementation of the Gale/Shapley algorithm in Python. This algorithm is designed to address the Stable Marriage Problem.

Compare this recursive variant with the implementations on Rosetta Code.

Problem description

Given an equal number of men and women to be paired for marriage, each man ranks all the women in order of his preference and each women ranks all the men in order of her preference.

A stable set of engagements for marriage is one where no man prefers a women over the one he is engaged to, where that other woman also prefers that man over the one she is engaged to. I.e. with consulting marriages, there would be no reason for the engagements between the people to change.