Joy, you have a response that broke new ground. You made it clear that you still don't understand the problem asked, nor do you understand the solution offered.

Part 3 of the specification said that if you tied on the first two criteria but had played head to head, then the winner should be ranked first except when that win is part of a cycle like the one where where A beats B beats C beats A. The challenge is therefore how to calculate which wins should be counted, and which wins are to be ignored because they are part of a cycle.

My solution was to take the transitive closure of the relation "won over". This is the relation "there is a chain of wins leading from one to the other." Once you have that transitive closure, you can easily find whether a particular win is part of a cycle. If A beat B, but there is a chain of wins from B to A, then A's win over B is part of a cycle and can't be used in that criteria. If A beat B and there is no chain of wins from B to A, then A's win can be used as a sorting criteria.

Now one can debate whether the best way to do this is to compute the whole transitive closure up front. But there is no way of solving the question asked without somehow being able to figure out whether a given win is part of an ambiguous cycle or not. And the process of doing that when A beat B is exactly the same as answering the question of whether (B, A) is in the transitive closure of the relation "won over". So you can't get away from dealing with the transitive closure, whether or not you use that language or whether you compute the whole thing or just part of it on demand.

Please note in particular that simply encoding wins in numbers in some fancy way will not readily let you know which wins are to be used as sorting criteria, and which need to be discarded as being ambiguous.


In reply to Re^8: Adding Special Rules to Sort by tilly
in thread Adding Special Rules to Sort by ctfishman

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.