Skip to content

Instantly share code, notes, and snippets.

View invegat's full-sized avatar

Mark Oliver invegat

View GitHub Profile
@invegat
invegat / README.md
Created March 23, 2020 18:16 — forked from joyrexus/README.md
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.