MMirrorVane
Product

Product features · Leftmost longest palindromes

01

Review palindrome.py for the tie rule that selects one palindrome when several maximal substrings exist.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Leftmost longest palindromes

● ● ●MirrorVane●
A concrete starting point · Leftmost longest palindromes ×
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]]
✳Leftmost longest palindromes
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗