* chore(i18n,curriculum): update translations * chore: Italian to italian Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
2.6 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| aaa48de84e1ecc7c742e1124 | Controllore di Palindromi | 5 | 16004 | palindrome-checker |
--description--
Restituisce true se la stringa data è un palindromo. Altrimenti, restituisce false.
Un palindromo è una parola o una frase che è scritta allo stesso modo sia in avanti che all'indietro, ignorando punteggiatura, maiuscole e minuscole e spaziatura.
Nota: Dovrai rimuovere tutti i caratteri non alfanumerici (punteggiatura, spazi e simboli) e trasformare tutto in maiuscolo o in minuscolo per verificare la presenza di palindromi.
Passeremo stringhe con diversi formati, come racecar, RaceCar e race CAR tra le altre.
Passeremo anche stringhe con simboli speciali, come 2A3*3a2, 2A3 3a2e 2_A3*3#A2.
--hints--
palindrome("eye") dovrebbe restituire un valore booleano.
assert(typeof palindrome('eye') === 'boolean');
palindrome("eye") dovrebbe restituire true.
assert(palindrome('eye') === true);
palindrome("_eye") dovrebbe restituire true.
assert(palindrome('_eye') === true);
palindrome("race car") dovrebbe restituire true.
assert(palindrome('race car') === true);
palindrome("not a palindrome") dovrebbe restituire false.
assert(palindrome('not a palindrome') === false);
palindrome("A man, a plan, a canal. Panama") dovrebbe restituire true.
assert(palindrome('A man, a plan, a canal. Panama') === true);
palindrome("never odd or even") dovrebbe restituire true.
assert(palindrome('never odd or even') === true);
palindrome("nope") dovrebbe restituire false.
assert(palindrome('nope') === false);
palindrome("almostomla") dovrebbe restituire false.
assert(palindrome('almostomla') === false);
palindrome("My age is 0, 0 si ega ym.") dovrebbe restituire true.
assert(palindrome('My age is 0, 0 si ega ym.') === true);
palindrome("1 eye for of 1 eye.") dovrebbe restituire false.
assert(palindrome('1 eye for of 1 eye.') === false);
palindrome("0_0 (: /-\ :) 0-0") dovrebbe restituire true.
assert(palindrome('0_0 (: /- :) 0-0') === true);
palindrome("five|\_/|four") dovrebbe restituire false.
assert(palindrome('five|_/|four') === false);
--seed--
--seed-contents--
function palindrome(str) {
return true;
}
palindrome("eye");
--solutions--
function palindrome(str) {
var string = str.toLowerCase().split(/[^A-Za-z0-9]/gi).join('');
var aux = string.split('');
if (aux.join('') === aux.reverse().join('')){
return true;
}
return false;
}