Questions tagged [palindrome]

A word, phrase, number, or other sequence of units that may be read the same way in either direction, forward or backward.

A word, phrase, number, or other sequence of units that may be read the same way in either direction, forward or backward.

Spacing and punctuation is generally ignored when attempting to determine whether the potential palindrome under consideration is in fact a palindrome. One such example is:

I, madam, I, made radio - so I dared! Am I mad? Am I?

(from http://www.joe-ks.com/palindromes.htm)

1763 questions
-1
votes
1 answer

For a 2d array of char check whether the characters can be rearrange to form a palindrome both rows wise and column wise

I came across this question on a coding website. Here we have to check whether the grid can be rearrange to form a palindrome both rows wise and column wise. My approach was first to check all the rows, and then columns. If any of them can not…
Max Newton
  • 13
  • 5
-1
votes
1 answer

Pseudo-code to check if an array is a palindrome

I am trying to write an algorithm/pseudo-code to check if a given array A is a palindrome using Stack.
Emanuel
  • 37
  • 8
-1
votes
2 answers

Binary representation palindrome in c++

i'm new to bitwise operators and I'm trying to show the palindrome representation of a number , for n= 32 ( 0010 0000 ) it should output 4 (0000 0100) but the values that it gives me are random, for example for the above input , instead of 4 , i…
-1
votes
1 answer

isPalindromic Function

I wrote this function isPalindromic for my compsci class where the professor wants us to better understand how library functions work. So he asked us to write a function isPalindromic and mine isn't working as well. Because there are so many parts,…
Vincent
  • 99
  • 5
-1
votes
1 answer

Palindrome (euler project)

I am trying solve this problem with Python: "Find the largest palindrome made from the product of two 3-digit numbers." This is my code: list_number = reversed(range(10000, 998002)) def check_number(x): for element in reversed(range(100,…
Mampel
  • 3
  • 1
-1
votes
2 answers

Haskell: How to read user input to be used in a function inside of a do block?

I am attempting to run a simple palindrome program in Haskell but I want to request input from the user to be used in the program. code: palindrome :: String -> Bool palindrome x = x == reverse x main = do putStrLn "Brendon Bailey CSCI 4200-DB" …
Bren Bailey
  • 11
  • 1
  • 1
  • 8
-1
votes
2 answers

palindrome or not practice program using user input

def reverse(string): return string[::-1] def isPalindrome(string): temp=reverse(string) if temp==string: return True else: return False string='tanmay' # input('enter a word') ans=isPalindrome(string) if ans==1: …
-1
votes
2 answers

reduce time complexity in checking if a substring of a string is palindromic

this is a simple program to check for a substring which is a palindrome. it works fine for string of length 1000 but gives TLE error on SPOJ for a length of 100000. how shall i optimize this code. saving all the substrings will not work for such…
Sohit Gore
  • 438
  • 1
  • 5
  • 13
-1
votes
1 answer

Project Euler Palindrome #4 with C

I found few posts regarding this problem using C. Most of the elements in my code work on their own but the iteration at the beginning is causing problems for some reason. First, I'm getting an "exited with non-zero status" error message. When I run…
seeess1
  • 155
  • 1
  • 1
  • 9
-1
votes
1 answer

Difference between char array[100] and char *array when calling functions?

i'd like to know why this code works fine with char tab[100] but doesn't work if I use char *tab ? fgets function takes a char* array as a parameter right ? #include #include #include Int Palindrome(char* str,…
-1
votes
1 answer

What is wrong with my java code for Project Euler's program 4? (finding the largest palindrome of 2 3 digit numbers)

This is my code and the answer always seems to 100001 (its not even performing the loop). I know there are much easier ways to solve this problem but what exactly is wrong with this particular code? and how do I fix it? public class…
-1
votes
3 answers

Javascript reverse a word check for palindrome and empty string

How to reverse a word and check if it is a palindrome and if an empty string is passed in javascript. here is what i came up with but not working as desired. function reverseString(str) { return str.split("").reverse().join(""); } am suppose to…
-1
votes
1 answer

Is it a palindrome in more than 1 base?

I quickly put together some Python code to test my knowledge. I'm trying to detect "multiple palindromes" without using strings. Here's my code: from math import log from math import ceil from math import floor palindrome = 0 def…
-1
votes
1 answer

Why am I seeing error when the number is 001? Please look at the code below to find the maximum palindrome sum from a given number

With number = 001, the error is 'invalid token'.. Please explain why and why 1 and 001 is not treated the same way by the compiler? number = 001 def palindrome(number): print ("The number is: ",number) str1 = str(number) strrev =…
777
  • 27
  • 6
-1
votes
3 answers

How to get the total count of palindrome words found in a sentence

I am working on a program which accepts a long string as input (a sentence). The program will check the string and count the number of palindrome words found then return the count. Example: input: _gig school level bye_ output: _2._ How can I get…
gl3yn
  • 301
  • 1
  • 3
  • 13
1 2 3
99
100