Tous les défis
Moyen 0 résolus 0 % de réussite

Recursive Palindrome

Check a palindrome recursively, ignoring case and punctuation.

Problème

Decide whether text reads the same forwards and backwards, considering only letters and digits and ignoring case. Solve it recursively: compare the outer characters, then check the inside.

Implement is_palindrome_recursive(text).

Input

text: The text to check (ASCII characters).

Output

Return true for a palindrome, otherwise false.

Contraintes

0 ≤ length ≤ 1,000

Exemples

Exemple 1
Entrée :
text = "Never odd or even"

Sortie attendue :
expected = True
Entrée :
std::string text = "Never odd or even";

Sortie attendue :
bool expected = true;
Entrée :
string text = "Never odd or even";

Sortie attendue :
bool expected = true;

Explication

Letters only, lowercased: "neveroddoreven" reads the same both ways.

Exemple 2
Entrée :
text = "code"

Sortie attendue :
expected = False
Entrée :
std::string text = "code";

Sortie attendue :
bool expected = false;
Entrée :
string text = "code";

Sortie attendue :
bool expected = false;

Explication

"c" and "e" differ, so it is not a palindrome.

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.