forked from GauravGupta035/TournamentFixtures_Round-Robin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.py
30 lines (25 loc) · 758 Bytes
/
backend.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
30
# Fixture generation code
def arr_rotate(arr):
x = []
x.append(arr[-2])
for i in range(0, len(arr) - 2):
x.append(arr[i])
x.append(arr[-1])
return x
def schedule(team_list):
l = len(team_list)
rotate = team_list
team_map = {1: 'DC', 2: 'PBKS', 3: 'RR', 4: 'KKR',
5: 'MI', 6: 'RCB', 7: 'SRH', 8: 'CSK'}
for i in range(l-1):
rotate = arr_rotate(rotate)
left = 0
right = l-1
print("-----Round ", i+1, " Fixtures-----")
while(left < right):
print("Team ", team_map[rotate[left]],
" Plays Team ", team_map[rotate[right]])
left += 1
right -= 1
l = list(map(int, input("Enter list ").split()))
schedule(l)