Connection
Base URL, credentials and a reachable server.
Review palindrome.py for the tie rule that selects one palindrome when several maximal substrings exist.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
def longest_palindrome(text):
if type(text) is not str or len(text) > 512:
raise ValueError("palindrome.input")
best = (0, 0)
for center in range(len(text)):
for left, right in ((center, center), (center, center+1)):
while left >= 0 and right < len(text) and text[left] == text[right]:
stop = right+1
if stop-left > best[1]-best[0] or (stop-left == best[1]-best[0] and left < best[0]):
best = (left, stop)
left -= 1
right += 1
return text[best[0]:best[1]]