-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_calendar.py
30 lines (24 loc) · 1.07 KB
/
generate_calendar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from itertools import permutations
import random
def generate_calendar(teams: list[int], id_championship: int):
list_matches = list(permutations(teams, 2))
random.shuffle(list_matches)
final_matches = list()
for x in range(0, len(list_matches), 2):
final_matches.append((list_matches[x], list_matches[len(list_matches)-x-1], id_championship))
return (id_championship, final_matches)
def generate_all_calendars(teams_per_championship):
matches_per_championship = []
for championship in teams_per_championship:
matches_per_championship.append(generate_calendar(teams_per_championship[championship], championship))
matches = list()
for journee in range(380//2):
matches.append(list())
for championnat in range(5):
matches_champ = matches_per_championship[championnat][1][journee]
matches[journee].append(matches_champ[0])
matches[journee].append(matches_champ[1])
for x in range(len(matches)):
tmp = tuple(matches[x])
matches[x] = tmp
return matches