Building a browser-first tournament and court scheduler looks deceptively simple until real-world club edge cases hit: 12 teams showing up for a 16-slot knockout draw, Double Elimination losers colliding with their Round 1 opponent again in Round 2 of the Lower Bracket, or 10 Pickleball / Padel players sharing 2 courts where static laminated charts break down immediately.
Here are the four deterministic TypeScript algorithms we used when engineering the client + Cloudflare Workers engine behind CourtBracket.com .
1. Recursive NCAA/ATP Fold Seeding & First-Round BYEs
To guarantee Seed #1 and Seed #2 sit on opposite halves of a knockout bracket—and Seeds #1..#4 occupy distinct quadrants—expand iteratively from [1, 2] up to B = 2^ceil(log2(N)) by folding each seed s against (layerSize + 1 - s) :
export function buildFoldedSeedOrder ( bracketSize : number ) : number [ ] { let seeds = [ 1 , 2 ] ; while ( seeds . length < bracketSize ) { const nextSize = seeds .…