-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgroup.py
More file actions
27 lines (22 loc) · 774 Bytes
/
group.py
File metadata and controls
27 lines (22 loc) · 774 Bytes
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
import random
from team import Team
class Group:
def __init__(self,name,teams):
self.name = name
self.teams = teams
self.scores = { team : 0 for team in self.teams}
def get_matches(self):
matches = []
for n,t in enumerate(self.teams):
for m,t2 in enumerate(self.teams):
if m <= n:
continue
matches.append((t,t2))
return matches
def Tie(self,team: Team):
self.scores[team.team_name] += 1
def Winner(self,team: Team):
self.scores[team.team_name] += 3
def get_groups_classifications(self):
a = sorted(self.scores.items(), key=lambda x: x[1], reverse=True)[:2]
return [i[0] for i in a]