Commit 5b8599d3 authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

added solution q5,q8

parent 5ea59557
import builtins
inputs=input()
inputString=str()
for i in range(int(inputs)):
inputString+=input()+" "
input=(inputString.split(' '))
matches={}
players={}
for i in input:
matchInfo=i.split(':')
matchName=matchInfo[0]
currentMatchDetails={}
if (len(matchInfo)<=1):
continue;
matchInfo[1]=(matchInfo[1]).replace('-',' ')
matchInfo[1]=matchInfo[1].replace(',',' ')
matchstats=matchInfo[1].split(' ')
j=0
while(j<len(matchstats)-1):
currentMatchDetails[matchstats[j]]=int(matchstats[j+1])
if(matchstats[j] in players):
players[matchstats[j]]+=int(matchstats[j+1])
else:
players[matchstats[j]]=int(matchstats[j+1])
j+=2
matches[matchInfo[0]]=currentMatchDetails
players=sorted(players.items() , key=lambda x: x[0],reverse=True )
players=dict(players)
players=sorted(players.items() , key=lambda x: x[1],reverse=True )
print(matches)
print(players)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment