Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
my comp be zoomin solution in Clear category for The Longest Palindromic by viktor.chyrkin
def longest_palindromic(a):
winner, comp = '', ''
for i, e in enumerate(a):
for b in a[i:]:
comp += b
if comp == comp[::-1] and len(comp) > len(winner):
winner = comp
comp = ''
return winner
if __name__ == '__main__':
print("Example:")
print(longest_palindromic('abc'))
# These "asserts" are used for self-checking and not for an auto-testing
assert longest_palindromic('abc') == 'a'
assert longest_palindromic('abacada') == 'aba'
assert longest_palindromic('artrartrt') == 'rtrartr'
assert longest_palindromic('aaaaa') == 'aaaaa'
print("Coding complete? Click 'Check' to earn cool rewards!")
Jan. 29, 2022