stable-marriage-problem
A javascript implementation of stable marriage problem, influenced by algorithm-archive
Installation
Use npm:
npm install stable-marriage
Or use yarn:
yarn add stable-marriage
Usage
const Person stableMarriage shuffle = const boys = ...'ABCD'const girls = ...'abcd' consolefor const boy of boys boy consoleconsolefor const girl of girls girl console consolefor const boy of boys if boyfiance console
Run the example code and your terminal should log like this:
boys
A: c,b,d,a
B: b,d,c,a
C: b,c,a,d
D: d,c,a,b
Girls
a: B,A,D,C
b: B,D,C,A
c: C,D,A,B
d: A,C,B,D
Pairings
A: d
B: b
C: c
D: a