Note that there are some explanatory texts on larger screens.

plurals
  1. POPairing off teams
    text
    copied!<p>The database contains a list of teams and each of these teams are separated by location (West team, East team, etc). There are two types of facts to describe this. team(TeamNumber, Losses) and region(TeamNumber, Region). For example:</p> <pre><code>team(1, 10). team(2, 11). team(3, 12). team(4, 13). region(1, east). region(2, west). region(3, east). region(4, southeast). </code></pre> <p>NOTE: The list of teams isn't always ordered from least losses to most losses.</p> <p>I'm trying to pair off a list of teams together so that the team with the highest losses is paired off with the team with the lowest losses and then the team with the second highest losses is paired off with the team with the second least losses, and ecetera ecetera. The rule is, pairing off teams within same regions is a priority. In the example above, teams 3 and 1 would be paired off together because they're both East teams. Now, the remaining teams are teams 2 and 4. But because no other team is in their region, teams 2 and 4 are matched against each other.</p> <p>Now, I'm thinking what function I can write to pair off the teams. I've already written a function to group up all the different teams within a region into a corresponding list. I've also written a function to get the minimum and the maximum (highest and lowest losses).</p> <p>How can I write a function(s) to pair off all the teams within the same region, and then make a new list sticking all the remaining teams in that list?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload