Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Keywords Finder by Moff
def checkio(text, words):
ltext = text.lower()
res = sorted((i, len(w)) for w in words.lower().split()
for i in range(len(text)) if ltext[i:].startswith(w))
highlight = []
if res:
highlight = [res[0]]
for i1, w1 in res[1:]:
i2, w2 = highlight[-1]
if i2 + w2 <= i1:
highlight.append((i1, w1))
else:
highlight[-1] = (i2, max(w2, i1 - i2 + w1))
result = ''
x = 0
for i, w in highlight:
result += '{}{}'.format(text[x:i], text[i: i + w])
x = i + w
result += text[x:]
return result
Aug. 19, 2015