Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for The Longest Palindromic by mercbeinp
def longest_palindromic(text):
for n in range(1, len(text)+1)[::-1]:
for m in range(len(text) - (n-1)):
if text[m:m+n] in text[::-1]:
return text[m:m+n]
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Dec. 27, 2017