0

I am currently working on the generation of a tournament bracket system, but I can't come up with a good algorithm for the following:

I have a List, where TournamentRound looks like follows:

public class TournamentRound
{
    public int TotalAtBeginning { get; set; }
    public int TotalAfterRound { get; set; }
    public int EntriesPerMatch { get; set; }
    public int WinnersPerMatch { get; set; }
}

I do have the generation of the rounds and do know all the values. E.g:

Round 1: 12 Participants, 4 Entries per Match, 2 Winners: 6 in the end
Round 2: 6 Participants, 2 Entries per Match, 1 Winner: 3 in the end
Round 3: 3 Participants, 3 Entries per Match, 1 winner: END

The following is my problem:

Let's say only 6 boxes do have space on one page of the final pdf. How can I calculate where the boxes are, given fix sizes of page and box?

EDIT for clarification!

Example output

I drew following picture to show what the output of those 3 rounds mentioned above would look like. The problem is e.g.: Only 6 boxes have space to fit on one page in height which means that somehow one would have to make a pagebreak for certain rounds.

If it helps, I'm thinking of building a tree-like structure where each node holds it's position and on which page (1,2,3...) it is.

Community
  • 1
  • 1
Shion
  • 1,499
  • 2
  • 14
  • 29
  • 1
    I'd love to help. But I don't fully understand what is your problem. What are the boxes? – Sergey Krusch May 02 '14 at 08:47
  • Do you want to have something like this? http://rekoholland.com/media/webimg/store/Pool-Tournament-Brackets.jpg – Sergey Krusch May 02 '14 at 08:52
  • @Shion It's really not getting clear, what do you mean by `box` and what a single box can contain. – Leron May 02 '14 at 09:14
  • I am really sorry. By box I mean one entry/participant of the whole tournament. In my example image, one box would be either one of the blue numbers. – Shion May 02 '14 at 09:23
  • @Shion Does that mean that a single bracket can be on more than one page (not enough space on the current page, or more than 6 boxes in a single bracket..)? – Leron May 02 '14 at 10:39
  • That is absolutely correct! – Shion May 02 '14 at 10:43

0 Answers0