def team():
N=int(input(""))
if N>=0 and N<=100:
teamsDetails = {}
for i in range(N):
items = input().split(';')
first_team = items[0].strip()
second_team = items[1].strip()
match_result = items[2].strip()
if(first_team not in teamsDetails):
teamsDetails[first_team]=[0,0,0,0,0]
if(second_team not in teamsDetails):
teamsDetails[second_team]=[0,0,0,0,0]
if(first_team in teamsDetails and second_team in teamsDetails):
teamsDetails[first_team][0]+=1
teamsDetails[second_team][0]+=1
if match_result == 'win':
teamsDetails[first_team][1]+=1
teamsDetails[second_team][2]+=1
elif match_result == 'loss':
teamsDetails[first_team][2]+=1
teamsDetails[second_team][1]+=1
elif match_result == 'draw':
teamsDetails[first_team][3]+=1
teamsDetails[second_team][3]+=1
for t in teamsDetails:
teamsDetails[t][4]=teamsDetails[t][1]*3+teamsDetails[t][3]
teamsDetails=(sorted(teamsDetails.items(), key = lambda points: points[1][4],reverse=True))
for t in teamsDetails:
ouput = f'Team: {t[0]}, Matches Played: {t[1][0]}, Won: {t[1][1]}, Lost: {t[1][2]}, Draw: {t[1][3]}, Points: {t[1][4]}'
print(ouput)
team()
Comments
Leave a comment