using System; using System.Collections.Generic; using System.Linq; namespace NBA { class Team { public long ID { get; set; } public Team(long id) { ID = id; } } class Group : List { } class Conference : List { } class Match { public Team Team1 { get; private set; } public Team Team2 { get; private set; } public Match(Team t1, Team t2) { Team1 = t1; Team2 = t2; } } class Program { static void Main(string[] args) { // 30 teams. // Each team must participate in 82 matches. // 1 league = 2 conference // 1 conference = 3 group // 1 group = 5 team // A team must play against: // Same group -> 4 times with 4 teams -> 16 // Same conference, other groups 4 times with 6 teams (out of 10) -> 24 // Same conference, other groups 3 times with 4 (out of ten) teams -> 12 // Ohter conference, 2 times with 15 teams -> 30 // Total 82 matches. List matches = new List(); List leage = new List(); var teamCursor = 1; // TODO: Calculate with a, b, c values. for (int a = 0; a < 2; a++) { var conference = new Conference(); for (int b = 0; b < 3; b++) { var group = new Group(); for (int c = 0; c < 5; c++) { var team = new Team(teamCursor++); group.Add(team); } var groupMatches = MatchTeamsInGroup(group); matches.AddRange(groupMatches); conference.Add(group); } leage.Add(conference); } Console.WriteLine(""); } static List MatchTeamsInGroup(Group group) { List matches = new List(); for (int i = 0; i < group.Count; i++) { for (int j = i+1; j < group.Count; j++) { for (int k = 0; k < 4; k++) { matches.Add(new Match(group[i], group[j])); } } } return matches; } static List MatchBlah(Group group) { List matches = new List(); for (int i = 0; i < group.Count; i++) { var groupCursor = (i / 5) + 1; for (int j = groupCursor * 5; j < group.Count; j++) { for (int k = 0; k < 4; k++) { matches.Add(new Match(group[i], group[j])); } } } return matches; } static List MatchTeamsBetweenGroups(Group myGroup, Group otherGroups) { var part1 = otherGroups.Take(6); var part2 = otherGroups.TakeLast(4); List matches = new List(); for (int i = 0; i < myGroup.Count; i++) { for (int j = 0; j < part1.Count(); j++) { for (int k = 0; k < 4; k++) { matches.Add(new Match(myGroup[i], part1.ElementAt(j))); } } for (int j = 0; j < part2.Count(); j++) { for (int k = 0; k < 3; k++) { matches.Add(new Match(myGroup[i], part2.ElementAt(j))); } } } return matches; } } }