Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The Longest Palindromic solution in Clear category for The Longest Palindromic by Seaclaid
def longest_palindromic(text):
odp=[]
for i in range(len(text)):
for j in range(0, i):
temp = text[j:i+1]
if temp==temp[::-1]:
odp.append(temp)
if len(odp)==0:
return text[0]
odp=max(odp,key=len)
print(odp)
return odp
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Jan. 14, 2017