Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Longest Palindromic by mdroz
def longest_palindromic(text):
pal2=""
for i in range(len(text)-1, -1, -1):
for j in range(len(text)-i+1):
prob_pal = text[i:][:j]
if prob_pal == prob_pal[::-1]:
pal = prob_pal
if len(pal) >= len(pal2):
pal2=pal
return pal2
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Nov. 14, 2017