Skip to content

Instantly share code, notes, and snippets.

@shashwata27
Created May 5, 2020 15:06
Show Gist options
  • Save shashwata27/a0c2fbcd5f149f4652d5ce843c4654fd to your computer and use it in GitHub Desktop.
Save shashwata27/a0c2fbcd5f149f4652d5ce843c4654fd to your computer and use it in GitHub Desktop.
Market Survey Season 8
QuestionNo=int(input())
ParticipentNo=int(input())
DefaultKey=input()
KeyRecord={}
lastkey=[0]*QuestionNo*5
def keyer(key,DK=False):
lastkeyindex=0
if not DK:
for y in range(ParticipentNo):
KeyRecord["Participant{0}".format(y)] = key
for x in range(0,QuestionNo*2,2):
if int(key[x])==0:
lastkey[lastkeyindex+0]+=1
lastkeyindex+=5
elif int(key[x])==1:
lastkey[lastkeyindex+1]+=1
lastkeyindex+=5
elif int(key[x])==2:
lastkey[lastkeyindex+2]+=1
lastkeyindex+=5
elif int(key[x])==3:
lastkey[lastkeyindex+3]+=1
lastkeyindex+=5
elif int(key[x])==4:
lastkey[lastkeyindex+4]+=1
lastkeyindex+=5
else:
print("invalid option")
keyer(DefaultKey,DK=True)
#print(KeyRecord)
#print(lastkey)
#keychecker
for x in range(ParticipentNo):
points=0
p=0
key=input()
for y in range(0,len(lastkey),5):
if int(key[p])==(lastkey.index(max(lastkey[y:y+5]),y,y+5))%5:
points+=1
p+=2
print(points)
keyer(key)
Finalpointrecords=[]
for itm in KeyRecord.values():
p=0
points=0
for y in range(0,len(lastkey),5):
if int(itm[p])==(lastkey.index(max(lastkey[y:y+5]),y,y+5))%5:
points+=1
p+=2
Finalpointrecords.append(points)
print(Finalpointrecords.index(max(Finalpointrecords))+1,max(Finalpointrecords))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment