Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Moria doors solution in Uncategorized category for Moria Doors by capback250
# migrated from python 2.7
__author__ = 'skoryakin'
def summator(source, target):
simmilar = 0
if source[:1] == target[:1]:
simmilar += 10
if source[-1:] == target[-1:]:
simmilar += 10
if len(source) <= len(target):
simmilar += len(source)/float(len(target))*30
if len(source) > len(target):
simmilar += len(target)/float(len(source))*30
simmilar += uniq(source, target)
return simmilar
def uniq(source, target):
non = []
un = set(source+target)
for x in source:
if x in target:
non.append(x)
for x in target:
if x in source:
non.append(x)
return len(set(non))/float(len(un))*50
def find_word(text):
n = {}
k = []
res = []
good_text = ''
for x in text:
if x.isalpha() or x == ' ':
good_text += x.lower()
for x in good_text.split():
k.append(x)
z = k[:]
while k:
label = k.pop()
n[label] = -100
for y in z:
n[label] += summator(label, y)
for x in n:
n[x] = n[x]/float(len(z)-1)
for key, value in n.items():
if value == max(n.values()):
res.append(key)
if len(res) == 1:
return res[0]
else:
return res[1]
Sept. 5, 2015