We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
withopen('trainingdata.txt')asfile:lines=file.readlines()heroes={}forlineinlines:line=line.strip().split(',')won=int(line[-1])fori,hinenumerate(line[:-1]):ifhnotinheroes:heroes[h]={'played':0,'won':0}heroes[h]['played']+=1if(i//5 == 0) and (won ==1): # h in 1st team and 1st team wonheroes[h]['won']+=1if(i//5 == 1) and (won ==2): # h in 2nd team and 2nd team wonheroes[h]['won']+=1forhero,dinheroes.items():heroes[hero]['p_won']=round(d['won']/d['played'],3)N=int(input())for_inrange(N):line=input().strip().split(',')t_1,t_2=line[:5],line[5:]p_1=sum([heroes[h]['p_won']forhint_1])p_2=sum([heroes[h]['p_won']forhint_2])ifp_1>p_2:w_pred=1else:w_pred=2print(w_pred)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dota 2 Game Prediction
You are viewing a single comment's thread. Return to all comments →