A palindrome reads the same forwards and backwards. Checking one takes a single pass with two pointers that walk inward from both ends. The same mirror idea finds the longest palindrome hidden inside a string, and it drives a number puzzle that is still open for 196.
First clean the phrase: keep only letters and digits, and lowercase them. Then put pointer L on the first character and R on the last. Compare, step both inward, repeat. One mismatch ends the search. A string of length n needs at most ⌊n/2⌋ comparisons.
How to read this: L and R start at both ends and step toward the middle, comparing one pair at a time. The small numbers under the tiles are positions, counting from 0.
A string is a palindrome exactly when character k equals character n−1−k for every k. The pointers visit those mirrored pairs once each, outermost first. When they meet, every pair has been checked; a middle character in an odd-length string has no partner and never needs one.
Switch to Raw string and the Panama phrase fails on its very first comparison, 'A' against 'a'. Cleaning is part of the definition you choose.
Every palindrome has a center: a letter for odd lengths, or the gap between two letters for even lengths. A string of n letters has 2n−1 centers. From each one, grow outward while the two new ends match. The longest run found is the answer, marked in gold.
How to read this: every letter and every gap between letters (the narrow columns) is a possible middle. From the ▼, the search grows outward while both ends match.
Try this: aaaa… to see the slowest case.
There are about n²/2 substrings, and checking each one with two pointers can cost up to n/2 more steps, so the brute force is O(n³). Expanding from a center reuses work: once "ee" is known to be a palindrome, "keek" needs just one more comparison.
Each center stops at its first mismatch, so a string with no repeated neighbors finishes in about 2n comparisons. A run of one letter such as aaaa… is the worst case, about n²/2. Manacher's algorithm reuses mirror information across centers to reach O(n).
Take a number, add it to its own digit reversal, and repeat until the sum is a palindrome. Most numbers get there fast: 87 takes 4 steps. 89 takes 24 steps and climbs to thirteen digits. For 196 nobody has ever found a palindrome, and nobody has proven that none exists.
A number that never reaches a palindrome this way is called a Lychrel number. No base-10 number has been proven to be one. 196 is the smallest candidate: computers have run its sequence to enormous lengths, and the sum keeps growing without ever reading the same both ways. Load it and watch the digit count climb.
Scanning 0 to 999…
This page stops after 500 steps. That is a limit of patience, not a proof. The sums here can run to hundreds of digits, so the arithmetic uses JavaScript's BigInt to stay exact.