Here is an exhaustive approach. This is rather like the N-queens problem that has been discussed here on PM a few times.

Here you probably want to solve for various sizes of the problem and save the tables for later use. If the event is mandating the number of players a school must bring, that would help.

Create a table containing each panel of each round. Each panel in the table contains a spot for every player in the event. In very simplistic progression load each panel in order, after each panel is loaded check for legality, if there is a conflict, back up, and try the next pattern in the progression. When you get to the last panel and have no conflicts you have a solution. Apparently you need only one per round.

This is a N-queens problem with one extra dimension. To simplify your problem for any particular case, solve for the next exact fit larger. That is if you have 100 players going into 21 panels add 5 dummy-players so your panels are all the same. (Dummy players so each school has the same number of players could help also.)

In the case above each panel could contain 5 player numbers. The progression for each panel could be:

0 0 0 0 0 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 # first possibly valid set, though having 1 2 3 4 6 # 1 2 3 be from the same school lets you 1 2 3 4 7 # quickly skip obviously invalid matchings ... # getting to something like 1 4 7 11 14 # <- fairly quickly ... 1 2 3 4 105 ... 1 2 3 104 105 ... 101 102 103 104 105 # last possible value
When a panel has reached its last value there is no point in backing into it -- all possiblities have been tried.

There are a lot of possibilities so look for efficiencies. Each round should not redo the work of the prior rounds but continue to solve from that position. Find the first and last non-self-conflict state for a panel for each round and eliminate checking some useless states.


In reply to Re: Perl for Adjudication by rir
in thread Perl for Adjudication by dejoha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.