Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Speedy category for Keywords Finder by blabaster
def checkio(text, words):
words, t, l = words.lower().split(), text.lower(), []
for i in range(len(t)):
ti = t[i:]
l.extend(([i, i + len(w)] for w in words if ti.startswith(w)))
l.sort()
for i in range(len(l) - 1, 0, -1):
for j in range(i - 1, -1, -1):
if l[i][0] < l[j][1]:
l[j][1] = max(l[j][1], l[i][1])
l.pop(i)
break
t = list(text)
for i, j in reversed(l):
t.insert(j, '')
t.insert(i, '')
return ''.join(t)
May 18, 2014