palindrome

function isPalindrome(sometext) {
  var replace = /[.,'!?\- \"]/g; //regex for what chars to ignore when determining if palindrome
  var text = sometext.replace(replace, '').toUpperCase(); //remove toUpperCase() for case-sensitive
  for (var i = 0; i < Math.floor(text.length/2) - 1; i++) {
    if(text.charAt(i) == text.charAt(text.length - 1 - i)) {
      continue;
    } else {
      return false;
    }
  }
  return true;
}
//EDIT: found this on https://medium.com/@jeanpan/javascript-splice-slice-split-745b1c1c05d2
//, it is much more elegant:
function isPalindrome(str) {
  return str === str.split('').reverse().join(''); 
}
//you can still add the regex and toUpperCase() if you don't want case sensitive

4.33
6

                                    //made by Kashish Vaid the great.
// Palindrome programme using for loop the easiest prgm
#include &lt;stdio.h&gt;
int main() {
    int n, rev = 0, remainder, num;
    printf(&quot;Enter an integer: &quot;);
    scanf(&quot;%d&quot;, &amp;n);
    num = n;

    // reversed integer is stored in rev
  for(num = n ; n!=0 ; n/=10)
{
    remainder = n%10;
    rev = rev*10 + remainder;
}
// if else shortcuts
    ( (rev == num) ? printf(&quot;%d is a palindrome.&quot;, num) : printf(&quot;%d is not a palindrome.&quot;, num) );
    return 0;
}
//made by Kashish Vaid the great.

4.33 (6 Votes)
0
4.33
3

                                    function isPalindrome(text) {
  return [...text].reverse().join('') === text;
}

isPalindrome = text =&gt; {
	return [...text].reverse().join('') === text;
}

isPalindrome = text =&gt; [...text].reverse().join('') === text;

4.33 (3 Votes)
0
4.67
3

                                    #include &lt;stdio.h&gt;
int main() {
    int n, reversedN = 0, remainder, originalN;
    printf(&quot;Enter an integer: &quot;);
    scanf(&quot;%d&quot;, &amp;n);
    originalN = n;

    // reversed integer is stored in reversedN
    while (n != 0) {
        remainder = n % 10;
        reversedN = reversedN * 10 + remainder;
        n /= 10;
    }

    // palindrome if orignalN and reversedN are equal
    if (originalN == reversedN)
        printf(&quot;%d is a palindrome.&quot;, originalN);
    else
        printf(&quot;%d is not a palindrome.&quot;, originalN);

    return 0;
}

4.67 (3 Votes)
0
5
1

                                    function Palindrome(str) { 

  str = str.replace(/ /g,&quot;&quot;).toLowerCase();
  var compareStr = str.split(&quot;&quot;).reverse().join(&quot;&quot;);

  if (compareStr === str) {
    return true;
  } 
  else {
    return false;
  } 

}

5 (1 Votes)
0
4
9
Igor Souza 110 points

                                    #include&lt;iostream&gt;
#include&lt;string&gt;
#include&lt;algorithm&gt;
bool IsPalindrome_true_false(const std::string&amp; );

int main ()
{
    
    std::cout&lt;&lt;&quot;Please enter a string:\t&quot;;
    std::string str;
    getline(std::cin, str);
    
    // convert the string from uppercase to lowercase 
    int i = 0;
    while(str[i])
    {
        if(str[i] == std::toupper(str[i]) &amp;&amp; std::isalpha(str[i]) == 1024)
        str[i]+= 32;
        ++i;
    }
    // looping while string is empty 
    while(str.empty())
    {
        std::cout&lt;&lt;&quot;\nPlease enter a string your string is empty:\t&quot;;
        if(!str.empty())
        std::string str;
        getline(std::cin, str);
    }
    
    std::cout&lt;&lt;&quot;\n&quot;&lt;&lt;std::boolalpha&lt;&lt;IsPalindrome_true_false(str)&lt;&lt;std::endl;
    std::cout&lt;&lt;std::endl;

    return 0;
}

// check if string is a palindrome and return true or false 
bool IsPalindrome_true_false(const std::string&amp; str)
{

    int i = 0;                
    int j = str.length() - 1; 

    while(i &lt;= j )
    {   
        
        if(std::isalpha(str[i]) == 0){
            ++i;
            continue;
        }else if(std::isalpha(str[j]) == 0){
            --j;
            continue;
        }   
        if(str[i] != str[j]){
        
           return false;
        }
        ++i;
        --j;
    }  
    return true;
}



4 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
palindrom numbers fastest way to check palindrome palindrome or not palindrome character palindromes numbers is 1 palindrome palindrome ++ how to check if a number is a palindrome Valid Palindrome I Special Palindrome.. what's palindrome string palindrome find the area is palindrome or not palindrome NITTIN palindrome online valid palindrome solution Palindrome Partioning palindrom code palindrome math its a palindrome what is the meaning of palindrome number what is the meaning of palindrome palindrome of number what i a palindrome algorithm for palindrome what is palindrome string palindrome pattern palindrome algorithme palindrome sentences palindrome number check palindromeCutting(s) 1. Define Palindrome. check if a string is a palindrome definition of Palindrome is valid palindrome short sentences that are palindromes what is the opposite of a palindrome how to check if string is palindrome properties of palindrome numbers WAHT IS Palindrome language palindrome numbers number is a palindrome palindrome examcodeples palindrome checker read palindrome number palindrome sentence examples how to calculate all palindrome numbers palindrome condition palindrome check if a given string is a palindrome? integer is a palindrome check type of palindrome palindrome type fastest way to check a number is palindrome cederbyte Palindrome check for palindrome in on time palindrom sentence how to find palindrome number valid palindrome string make my name palindrome palindrome number in Is Palindrome Possible? given string is a palindrome what is a palindrome integer what palindrome means palindrome formula palindrome + palindrome check number is palindrome or not palindrome app do whats a palindrome app do make a string palindrome do palindrome what are palindromes numbers requirement of palindrome length of palindrome palindrome program explanation palindrome exemple i palindrome i 5. Palindrome palindrome functionC nombre palindrome algorithme what are palindrome numbers what are palindrome numbersa explication palindrome form a palindrome palindrome define palindrome number checker palindrome numbers? How do you check if a given string is a palindrome? palindrome esope palindrome amma palindrome nombre is 'a' palindrome Palindrome number. facts about palindrome un palindrome un palindrome) number is palindrome exemple palindrome palindrome index palindrom definition palindrome character what's a palindrome number palindrome sentece what does palindrome mean palindromes definition palindrome create palindrome example is palindrome algorithm Make it a Palindrome what is a palindrome ? storia palindrome that are palindrome palindrome solution number palindrome palindrome example definition of a palindrome palindrome en algorithme palindrome fucntion example of a palindrome famous palindrome is 'a' a palindrome Checking Palindrome find palindromes example of palindrome palindrome algorithm number The Palindrome check palindrome what is the palindrome palindrome atcodre palindrome function A palindrome is palindrome values palindrome integer palindrome ,symentry palindrome numcer palindrome salam i whats palindrome is a palindrome is this a palindrome palindrome check what do you mean by palindrome palindrome defintiion meaning of palindrome palindromi palindrome algorithm features of a palindrome is a. a palindrome properties of a palindrome palindrome in define palindrome what is a palindrome number palindrome def palindrome in scheme palindrome meaing PALINDROME NAME Valid Palindrome Palindrome number. palindrome mean palindrome number palindrome code example of palindrome words palindrome scheme long words that are palindromes examples of palindrome words show me palindromes what is palindrome number palindrome number in c++ number is palindrome or not palindrome word pronounce palindrome A PALINDROME example forwards and backwards words palindrome problem palindrome means is 26 a palindrome palindrome 8086 palindrome in 8086 palindrome c palindrome examples words palin drome sentence palindrome number meaning palindrome recursion is single character palindrome? palindrome strings examples palindrome definition the meaning of palindrome word forward and backward read whaqt is a palindrome palindrome defintion Palindrome. palindromes list 10 alphabet pallendrome word that's the same backwards palindrome sentence example not palindrome words sentence with palindrome words palindrome dictionary what is it called when a word is the same backwards palindorme string name palindrome an example a palindrome long palindrome racecar word backwards what words are spelled the same backwards What is this start at the bottom and read each line backward, saying all the important characters? examples of palindrome bioternary same words from both sides palindrome' what is the name of a word that is spelled the same forwards and backwards phrase palindrome palyndrome palendrom text palindrome meaning computer whart is palindrome palindromic words palindromes example palindrome sentence What is the palindrom words palindrome words palindrome m palindrome word palindrome one expression word palindromes cool palindrome sentences palindrome orde word palindrpmes list of palindromes whats is a palindrome is palindrome whta is palindrome what is. a palindrome whats a palindrome large palindrome words palindrome meaning long palindrome sentence what is a palindrome palindrome english palindrome examples what is palindrome palindrome
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source