Last active
October 21, 2021 15:42
-
-
Save mikeyakymenko/369eba0fb4b5e68ea4586b8181b6fc20 to your computer and use it in GitHub Desktop.
Revisions
-
mikeyakymenko revised this gist
Oct 21, 2021 . 1 changed file with 28 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,30 @@ def scheduleMatches(teams, rounds=1): matches = [] if len(teams) % 2 == 1: teams.append('None') teamsNumbers = len(teams) map = list(range(teamsNumbers)) middle = teamsNumbers // 2 for i in range((teamsNumbers-1)*rounds): map1 = map[:middle] map2 = map[middle:] map2.reverse() round = [] for j in range(middle): team1 = teams[map1[j]] team2 = teams[map2[j]] if team1 != 'None' and team2 != 'None': if i % 2 == 1: round.append((team2, team1)) else: round.append((team1, team2)) matches.append(round) map = map[middle:-1] + map[:middle] + map[-1:] return matches def schedule_cross_conf(conf_a, conf_b, rounds=1): matches=[] size = len(conf_a) @@ -22,4 +49,4 @@ def schedule_cross_conf(conf_a, conf_b, rounds=1): conf_a = conf_a[1:] + conf_a[:1] conf_b = conf_b[1:] + conf_b[:1] return matches -
mikeyakymenko created this gist
Oct 21, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ def schedule_cross_conf(conf_a, conf_b, rounds=1): matches=[] size = len(conf_a) for i in range(size*rounds): conf_a.reverse() round = [] for j in range(size): team_a = conf_a[j] team_b = conf_b[j] if i+1 <= size: if i % 2 == 1: round.append((team_a, team_b)) else: round.append((team_b, team_a)) else: if i % 2 == 1: round.append((team_b, team_a)) else: round.append((team_a, team_b)) matches.append(round) conf_a = conf_a[1:] + conf_a[:1] conf_b = conf_b[1:] + conf_b[:1] return matches