Hi! :)
Below you'll find my (n00bish & non pythonian) solution for the MWL mission and as far as i see it returns the proper result (even the checkbox states: for hello world: "your result 'l', right result is 'l'). Nevertheless the mission is indicated as failed. Can you tell me why?
Thanks in advance!
Keep up the great work - this site totally rocks!!
Regards,
Grinny
From: http://www.checkio.org/mission/most-wanted-letter/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9
import re
from collections import Counter
text = text.lower()
mostWFind = re.findall(r'[a-z]', text)
mostWList = []
mostWDict = {}
for i in mostWFind:
mostWList.append(mostWFind.count(i))
mostWDict = dict(zip(mostWFind, mostWList))
maxval = max(mostWDict.values())
keys = [x for x, y in mostWDict.items() if y ==maxval]
keys = sorted(keys)
return sorted(keys[0])
Created at: 2016/01/14 21:19; Updated at: 2016/01/15 19:13