Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
TheLongestPanlidromic solution in Clear category for The Longest Palindromic by Olus202
def palindromic(palin):
if palin == palin[::-1]:
return True
return False
def longest_palindromic(text):
longestpalin = ""
for m in range(len(text)):
for n in range(len(text) + 1):
palin = text[m:n]
if palindromic(palin):
if len(palin) > len(longestpalin):
longestpalin = palin
return longestpalin
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaaa", "The A"
May 19, 2016