CCalclabhub

Text & Writing

Palindrome test

A string is a palindrome when reversing it produces exactly the same string, which is true for racecar and for a sentence once its spaces and capitals are removed.

Last updated

The Formula

s is a palindrome if reverse(s) = s

A string is a palindrome when reversing it produces exactly the same string, which is true for racecar and for a sentence once its spaces and capitals are removed.

SymbolMeaning
sText

What Each Symbol Means

sstring

Text

The candidate string.

See It Worked With Real Numbers

A formula on its own does not tell you which number goes where. The how to reverse text page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.

Where This Formula Appears

This equation is the working core of How To Reverse Text, filed under Everyday Life. Every number the guide produces comes from substituting into this one line.

Common Questions

What is the formula for Palindrome test?

The formula for Palindrome test is s is a palindrome if reverse(s) = s. A string is a palindrome when reversing it produces exactly the same string, which is true for racecar and for a sentence once its spaces and capitals are removed.

What units should I use with Palindrome test?

Substitute s in string. Convert every input to those units before you start, because the equation only returns the right answer when the units on both sides agree.

What is a common mistake when using Palindrome test?

Separating the accent from its letter. If an accented letter is stored as a base plus a combining mark, reversing the units moves the mark. Normalise the text first or reverse by grapheme cluster.