Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Moria Doors by Tinus_Trotyl
def find_word(message):
words = [w for w in "".join(c if "a" <= c <= "z" else "|" for c in message.lower()).split("|") if w]
most_score, most_word = 0, ""
for i, word in enumerate (words):
score, otherwords = 0, words[:i] + words[i+1:]
for other in otherwords:
score += 10 * (bool(word[0] == other[0]) + bool(word[~0] == other[~0]))
score += 30 * min(len(word),len(other)) / max(len(word),len(other))
score += 50 * len(set(word) & set(other)) / len(set(word) | set(other))
score = round(score, 3)
if score >= most_score:
most_score, most_word = score, word
return most_word
Oct. 11, 2017
Comments: