Creating A Auto-Generated Fixture List

Discussion in 'Programming' started by Omission, Apr 11, 2007.

  1. #1
    Ok this is a pretty basic but elaborate problem :confused:

    I have a list contriving of the ID's of some teams, i want to create a method that can create a fixture list so that every ID plays each other regardless of how many IDs are in the list.

    For example:

    tid_list = "1,2,3,4"

    to produce

    1 v 2
    1 v 3
    1 v 4
    2 v 3
    2 v 4
    3 v 3
    3 v 4

    Brains a bit frazzled so sorry if the explaination is a bit fuzzy, any one had any experience with this and recommend a way of doing it.

    I'm currently attempting to do it by cycling through the lists with loops and incrementing the ListGetAt value but not having much luck.
     
    Omission, Apr 11, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The "3 v 3" is a typo right? Maybe something like this..

    <cfset tid_list = "1,2,3,4">
    <cfoutput>
    <cfloop from="1" to="#listLen(tid_list)#" index="x">
    <cfloop from="#(x+1)#" to="#listLen(tid_list)#" index="y">
    #x# v #y#<br>
    </cfloop>
    </cfloop>
    </cfoutput>
     
    cfStarlight, Apr 11, 2007 IP
  3. Omission

    Omission Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thats spot on thanks, my poor brains taken a hammering these past couple of days and just couldn't grasp it.

    Thanks again, although there are certain conditions i'm going to have to apply to the results of that list so i may be back here a bit later on :)
     
    Omission, Apr 11, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, we've all had those days!

    If the team ids come from a db table I was almost going to suggest using a cross join. But you've got to be very careful with those. They can generate very large result sets. So only use them if you know what you're doing ;)
     
    cfStarlight, Apr 11, 2007 IP