Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
longest palindromic solution in Clear category for The Longest Palindromic by Nirmala
def longest_palindromic(text):
t = ""
p = ""
pt = ""
w = text
for item in text:
t = item.lower() + t
while not t == text:
t = ""
text = text[0:-1]
for item in text:
t = item.lower() + t
text = w
while not p == text:
p = ""
text = text[1:]
for item in text:
p = item.lower() + p
text = w
while not pt == text:
pt = ""
text = text[1:-1]
for item in text:
pt = item.lower() + pt
if len(t) >= len(p) and len(t) >= len(pt):
return t
elif len(p) > len(t) and len(p) > len(pt):
return p
elif len(pt) > len(t) and len(pt) > len(p):
return pt
Jan. 3, 2017