Stable Matching Generator
The deferred acceptance algorithm underlies medical residency matching and school placement worldwide, and its guarantee is precise: no pair left unmatched would both rather have each other. This generates preference lists for both sides, runs the algorithm, and then checks that guarantee directly — by testing every single unmatched pair rather than trusting the procedure that produced them.
What this generator does
Generates a complete preference ranking for everyone on both sides, runs deferred acceptance, and then tests every unmatched pair to see whether both would prefer each other to their current partner.
How to use this tool
- Choose how many are on each side.
- Generate, and read the matches.
- Check the preference lists: notice the proposing side does better.
- Look at the stability verdict, which is checked pair by pair.
Understanding the controls
- How many on each side
- Between 2 and 6. Everyone ranks everyone on the other side in full, so the number of preference lists grows quickly.
- Seed
- Reproduces the same preferences, which matters when the same scenario needs to be worked through by hand.
Common use cases
- Demonstrating deferred acceptance with full preference data
- Teaching what stability means as a testable property
- Showing why the proposing side has an advantage
- Producing matching examples for an algorithms or economics class
- Generating test cases for a matching implementation
How this generator works
Free proposers work down their preference lists; each receiver holds the best offer so far and rejects the rest, so a proposer can be displaced later by someone the receiver prefers. That is why it is called deferred acceptance, and it is what guarantees termination with a stable result. Stability is then checked rather than assumed: for every proposer, every receiver they prefer to their current partner is examined to see whether that receiver also prefers them — a single such pair would make the matching unstable, and none may exist.
Randomness and fairness
Uses your browser's cryptographic random source for the preference lists by default. A seed switches to a reproducible sequence, which is deterministic and not cryptographically secure.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Both sides are the same size and everyone ranks everyone, so unacceptable partners and unequal sides are not modelled.
- One partner each: the hospital-residency variant where one side takes several is a direct extension but is not implemented here.
- The proposing side gets its best possible stable outcome and the other side its worst, so who proposes is a real design decision rather than a detail.
- Preferences are random rather than correlated, whereas real preference lists often share a broad consensus about who is desirable.
Privacy and your data
Preferences and matches are generated in your browser and never transmitted, stored or included in analytics.
Related generators
- Ranked Ballot Election GeneratorCounts the same ranked ballots four ways and shows where the methods disagree, with the head-to-head table built independently of all of them.
- Fair Division GeneratorSplits indivisible items between people who value them differently, then asks each of them whether they would rather have someone else's share.
- Auction Mechanism GeneratorRuns the same private values through a first-price and a second-price auction, proving by enumeration that honest bidding cannot be beaten in the second.
- Group Stage and Knockout GeneratorDraws the groups and the knockout bracket they feed, checking the arithmetic that decides whether the two halves actually fit together.