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 Michal_Cichy
def palindrom(text):
if text==text[::-1]:
return True
else:
return False
def longest_palindromic(text):
najdluzszy=""
for c in range(len(text)):
for b in range(c,len(text)+1):
if palindrom(text[c:b]):
biezacy=text[c:b]
if len(biezacy)>len(najdluzszy):
najdluzszy=biezacy
return najdluzszy
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Dec. 4, 2016