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.


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]}


Your output should resemble the examples below, and must follow these rules:

  1. For each round in the tournament, the entrants are paired up and those pairs are output.
  2. 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).
  3. 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.
  4. The best seeds should be first in the pair, and at the top of the bracket.
  5. 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
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

Extra props for anyone who codes a separate version of their program which prints an actual bracket.


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!

  • \$\begingroup\$ @Geobits Good catch! I've changed/clarified the rules around bye weeks. I also changed the seed lingo to "best" and "worst". \$\endgroup\$
    – Rip Leeb
    Commented Nov 20, 2014 at 17:09
  • \$\begingroup\$ @FryAmTheEggman I've made the output requirements specific and added bracket output as extra. Thanks! \$\endgroup\$
    – Rip Leeb
    Commented Nov 20, 2014 at 17:13
  • \$\begingroup\$ @Optimizer I will say no, since any additional input would probably indicate pre-processing or decision making outside of the program. \$\endgroup\$
    – Rip Leeb
    Commented Nov 20, 2014 at 19:33
  • \$\begingroup\$ @Optimizer Are you trying to avoid declaring a variable in your code by stuffing variables into the input? I'll still say no, unless you explain the legitimacy of it. \$\endgroup\$
    – Rip Leeb
    Commented Nov 20, 2014 at 19:40
  • 1
    \$\begingroup\$ You got me :D :D \$\endgroup\$
    – Optimizer
    Commented Nov 20, 2014 at 19:42

1 Answer 1


CJam, 156 151 144 bytes

q~0f+{{1=}$_,2%{{W=}$())+aa\{1=}$\}L?\_,2//)W%a+z\+_{0f=_,1={~" BYE"+a}*" vs "*N\}%"Round "U):U+\+\{{2=0=}$W=_2=(;2\t}%_W=2=}g~0=a"Champion"\]N*

This can definitely be golfed further.

The input is in an array of array format, like:

[["James" 1 [12 6 15]] ["Sarah" 4 [3 2 5]] ["Franko" 2 [20 1 5]] ["Max" 5 [22 10 7]] ["Arthur" 3 [20 15 20]]]

where each array element is the detail about the user in [name seed score_array] format

The output for the above input is:

Round 1
Franko vs Max
Arthur vs Sarah
James BYE
Round 2
James vs Max
Arthur BYE
Round 3
Arthur vs Max

Try it online here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.