You are on page 1of 2

#GrPA 1

results = [ ]
for i in range(8):
L = input().split(',')
winner = L[0] # the first team is the winner
losers = L[1: ] # all these teams have lost to the winner # we only need the
number of wins and the winning team
results.append((winner, len(losers)))
table = [ ]
# two-level-sort, first by points, then by name
# refer GrPA-4 of week-6
while results != [ ]:
maxteam = results[0]
for i in range(len(results)):
team = results[i]
if team[1] > maxteam[1]:
maxteam = team
elif team[1] == maxteam[1] and team[0] < maxteam[0]:
maxteam = team
results.remove(maxteam)
table.append(maxteam)
for team in table:
print(f'{team[0]}:{team[1]}')

#GrPA 2

def merge(D1, D2, priority):


if priority=='first':
for i in D2:
if i not in D1:
D1[i]=D2[i]
return D1
if priority=='second':
for i in D1:
if i not in D2:
D2[i]=D1[i]
return D2

#GrPA 3

def minor_matrix(M, i, j):


l=[]
for a in range(len(M)):
t=[]
if a==i:
continue
else:
for b in range(len(M[0])):
if b==j:
continue
else:
t.append(M[a][b])
l.append(t)
return l

#GrPA 4
n=int(input())
station_dict={}
for i in range(n):
m=input()
a=int(input())
d={}
for i in range(a):
s=input().split(',')
d[s[0]]=int(s[1])
station_dict[m]=d

You might also like