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 flpo
def substrings(string):
l = len(string)
for n in range(l, 0, -1):
for i in range(l - n + 1):
yield string[i:n+i]
def longest_palindromic(string):
return next(sub for sub in substrings(string) if sub == sub[::-1])
Sept. 25, 2017