Skip to content

Instantly share code, notes, and snippets.

@jbueza
Created April 17, 2014 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbueza/11002634 to your computer and use it in GitHub Desktop.
Save jbueza/11002634 to your computer and use it in GitHub Desktop.
Calculate number of rounds in a losers bracket (double elimination)
Math.ceil( (Math.log(teams)/Math.log(2)) / Math.log(2)) / Math.log(2)) + Math.ceil(Math.log(teams)/Math.log(2))
var teams = 128;
var initialRounds = Math.ceil(Math.log(teams)/Math.log(2));
var surplus = Math.ceil( Math.log(initialRounds)/Math.log(2) );
console.log(initialRounds);
console.log(surplus);
console.log("Total Rounds in Losers Bracket: " + initialRounds + surplus);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment