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 Chocolater
def longest_palindromic(text):
if text == text[::-1]:
return text
else:
return max(longest_palindromic(text[:-1]),
longest_palindromic(text[1:]), key = len)
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
May 30, 2018