Commit 76dace57 authored by Sanjna's avatar Sanjna

Upload new file

parent c4b5fbe8
import functools as ft
import sys
import re
fname = str(sys.argv[1])
f = open(fname,'r')
line = f.readline()
names = re.sub(' +',' ',line).split(" ")
mapping ={key:0 for key in names}
uniques=[]
for name in names:
if name not in uniques:
uniques.append(name)
most=0
lucky=""
for name in names:
mapping[name]+=1
if mapping[name]>most:
most=mapping[name]
lucky=name
elif mapping[name]==most:
if(uniques.index(name) < uniques.index(lucky)):
lucky = name
most=mapping[name]
print(lucky)
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