This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 1,000,000+ packages pre-installed, including
robin-js with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
It can be used directly in the browser, as a ES6 module, or as a CommonJS module in Node.
npm i robin-js
participants(Number, or Array of strings): the number of participants or an array that contains their names.
randomStart(Boolean): whether the pairing logic should start from the first participant or a random one (defaults to false).
rounds(Number, positive integer): the number of rounds required (defaults to a full round-robin).
Returns an array containing all the rounds. Each round is an array containing all the pairs. Each pair is an array containing the members.
If the number of participants is odd, at each round one different player will be alone (i.e. free / not paired).
import pairsCalc from 'robin-js'; // ES6 const pairsCalc = require('robin-js'); // CJS pairsCalc(4); // [ [ [ 1, 3 ], [ 2, 4 ] ], // [ [ 1, 2 ], [ 4, 3 ] ], // [ [ 1, 4 ], [ 3, 2 ] ] ] pairsCalc(['Tom', 'Lucy', 'Hannah']); // [ [ [ 'Lucy' ], [ 'Tom', 'Hannah' ] ], // [ [ 'Tom' ], [ 'Hannah', 'Lucy' ] ], // [ [ 'Hannah' ], [ 'Lucy', 'Tom' ] ] ]