Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Longest Palindromic by arcan.run
def longest_palindromic(txt):
max=''
for i in range(len(txt)):
for j in range(len(txt)):
out = txt[j:j+i+1]
# print(out)
# print(i, j+i)
if out == out[::-1]:
# print(out)
if len(max) < len(out):
max = out
return max
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
April 25, 2018