Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
re.findall(pattern, string) solution in Clear category for Moria Doors by David_Jones
import re
def likeness(s,t):
return 10 * ((s[0]==t[0])+(s[-1]==t[-1])) \
+ 30 * min(len(s),len(t)) / max(len(s),len(t)) \
+ 50 * len(set(s)&set(t)) / len(set(s+t))
def find_word(message):
words = re.findall('\w+', message.lower())
return max(
reversed(words), key=lambda x: sum(likeness(x,word) for word in words)
)
June 30, 2019