1.2.0 • Published 2 years ago

roundrobin-tournament-js v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Round Robin Tournament

Easily schuedule tournaments using Round Robin algorithm. A Round Robin algorithm creates an "all-play-all" tournament, where every team plays against each other. (usually in two rounds, where each one is the home team once). Round Robin Tournament makes it automatically for you.

Installation

$ npm install roundrobin-tournament-js

Usage

To create a Round Robin Tournament you just need to create an array with any elements and pass it as a parameter to the roundrobin function.

const roundrobin = require('roundrobin-tournament-js');

const teams = ["Liverpool", "Manchester United", "Arsenal", "Chelsea"];
const tournament = roundrobin(teams);

console.log(tournament);

/*
  output:

  [
    [ [ 'Liverpool', 'Chelsea' ], [ 'Manchester United', 'Arsenal' ] ],
    [ [ 'Chelsea', 'Manchester United' ], [ 'Arsenal', 'Liverpool' ] ],
    [ [ 'Arsenal', 'Chelsea' ], [ 'Liverpool', 'Manchester United' ] ]
  ]

*/

auto-generate second rounds by setting to true the second parameter:

const teams = ["Liverpool", "Manchester United", "Arsenal", "Chelsea"];
const tournament = roundrobin(teams, true);

console.log(tournament);

/*
  output:

  [
    [ [ 'Liverpool', 'Chelsea' ], [ 'Manchester United', 'Arsenal' ] ],
    [ [ 'Liverpool', 'Manchester United' ], [ 'Arsenal', 'Chelsea' ] ],
    [ [ 'Arsenal', 'Liverpool' ], [ 'Chelsea', 'Manchester United' ] ],
    [ [ 'Chelsea', 'Liverpool' ], [ 'Arsenal', 'Manchester United' ] ],
    [ [ 'Manchester United', 'Liverpool' ], [ 'Chelsea', 'Arsenal' ] ],
    [ [ 'Liverpool', 'Arsenal' ], [ 'Manchester United', 'Chelsea' ] ]
  ]

*/

License

MIT License. Copyright (c) 2022

1.2.0

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago