Your task is to create a program which outputs a completed tournament bracket given a list of entrants, their seeds, and their scores in each game; in the fewest characters possible.
Input
Your entrants will have the following data. You can organize your data in whatever form you like, but you cannot pre-sort your array or do any other pre-processing. The scores represent an entrant's score in each round, in other words they determine who moves on to the next round.
Example Input #1
[ {name: "James", seed: 1, scores: [12, 6,]}
, {name: "Sarah", seed: 4, scores: [1, 16]}
, {name: "Andre 3000", seed: 3, scores: [3000, 3000]}
, {name: "Kim", seed: 2, scores: [20, 4]}
]
Example Input #2
[ {name: "Andy", seed: 1, scores: [1, 8, 4]}
, {name: "Kate", seed: 4, scores: [1, 1, 8]}
, {name: "Steve", seed: 3, scores: [30, 1, 0]}
, {name: "Linda", seed: 5, scores: [4, 4, 5]}
, {name: "Kyle", seed: 2, scores: [21, 0, 18]}
]
Output
Your output should resemble the examples below, and must follow these rules:
- For each round in the tournament, the entrants are paired up and those pairs are output.
- In the event of an odd entrant count, your program must account for and output byes. The entrant who gets the bye is the entrant who has been given the fewest bye weeks so far, and in the event of a tie, the best seed (1 is the best).
- Pairing is based on the seed. Excluding byes, the best seed (1 is the best) is paired with the worst, the next best is paired with the next worst seed, etc.
- The best seeds should be first in the pair, and at the top of the bracket.
- The tournament champion should be output.
.
Example Output #1 (for input #1)
Round 1
James vs Sarah
Kim vs Andre 3000
Round 2
James vs Andre 3000
Champion
Andre 3000
Example Output #2 (for input #2)
Round 1
Kyle vs Linda
Steve vs Kate
Andy BYE
Round 2
Andy vs Steve
Kyle BYE
Round 3
Andy vs Kyle
Champion
Kyle
Extra props for anyone who codes a separate version of their program which prints an actual bracket.
Scoring
Assume input is correct, standard loopholes, etc and so forth. This is code golf, so fewest bytes win. In the event of a tie, most votes win. Good luck!