Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear solution in Clear category for The Longest Palindromic by martin_b
def longest_palindromic(t):
lt = len(t)
for l in range(lt, 0, -1):
for i in range(lt - l + 1):
p = t[i:l + i]
if p == p[::-1]:
return p
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
March 2, 2016