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!
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.