Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Matching lab

Pair two groups by their preference lists with the Gale-Shapley algorithm: round-by-round steps, stable results for either side, and a checker for blocking pairs.

Round by round

    How to use

    1. Write one line per person: the name, a colon, then every person in the other group from first choice to last, separated by commas. Both groups need the same number of people.
    2. Choose which group proposes and press Match. The table shows the pairs and how each person ranked their partner; the list below shows every round.
    3. Try Make random lists for bigger examples, and switch who proposes to see which side gains.
    4. Check your own pairs tests any matching you build and names the pairs that would break away.

    Keyboard and touch

    TabMove between tabs, boxes and buttons
    Enter in a one-line boxMatch again

    Tips

    • A matching is stable when no two people both prefer each other to the partner they got. The algorithm always finds one.
    • The proposing side does best: every proposer gets the best partner they could have in any stable matching. Compare the rank totals.
    • When both directions give the same answer, there is only one stable matching.
    • Proposers can never gain by lying about their list, but receivers sometimes can.

    About the method

    David Gale and Lloyd Shapley described deferred acceptance in 1962. In each round every unmatched proposer asks the next person on their list; each person asked keeps the best offer they have had so far and turns down the others, who try again next round. It ends after at most n² offers. Versions of it match junior doctors to hospitals and pupils to schools in many countries; Shapley and Alvin Roth shared the 2012 economics Nobel Prize for this work. This page needs complete lists and equal groups; real schemes add capacities and ties. Everything runs in your browser.

    See you tomorrow!

    A fresh daily puzzle every morning, and new tools added every month.

    Browse every product