Tournament Bracket Code Challenge
Music for reading(Spotify) (or Apple Music)
For those that don’t know me, I am a huge fan of video games. My favorite thing about video games, is the comradery it forges in the kiln of competition. I love getting together with friends to hang out and play games together. So much so, I started organizing small LAN parties that grew into fairly big LAN parties. As the LANs grew, so did a need for management/registration software.
In building our own LAN management web application, the job of building a tournament generator fell to me. It was a task that stretched me as a relatively new developer. I recently went back to refactor the code I had slaved over years ago and thought it would be a decent challenge to pose to other developers.
I proposed this code challenge to the fine folks at the Vancouver(US) Ruby Meetup on June 15, 2017. I will be going over my refactored solution at the next meetup (and updating this post). Below is my challenge to you!
- Build a tournament Bracket
- The Bracket must have structure
- Allow for any number of entrants
- The Bracket must have a winner
Build A Tournament Bracket
At its most basic it should look something like this:
Or more complex:
This type of bracket is a single-elimination type of tournament. After a team loses once, they are out of the tournament.
The Bracket Must Have Structure
Teams must advance through the tournament as it is built. You cannot just throw teams randomly into the next round:
Allow for Any Number of Entrants
In the example below, there are only 7 teams. So you have to give a random team a Bye in the first round.
The Bracket Must Have A Winner
There must be a way of advancing teams through the bracket to determine a winner.