Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Moria Doors by gyahun_dash
import re
def getscore(word1, word2):
first = 10 if word1[0] == word2[0] else 0
last = 10 if word1[-1] == word2[-1] else 0
length = 30 * min(len(word1) / len(word2), len(word2) / len(word1))
unique = 50 * len(set(word1) & set(word2)) / len(set(word1) | set(word2))
return first + last + length + unique
def find_word(message):
words = re.findall('[a-z]+', message.lower())[::-1]
return max(words, key = lambda w: sum(getscore(w, x) for x in words))
Sept. 24, 2014
Comments: