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
0
votes
2 answers

How to check if an appropriate enumerable is a palindrome

Obviously, a hash would not work for this kind of test. Anyways, here's what I have so far: module Enumerable def palindrome? arr = [] self.reverse_each do |x| arr << x end self == arr end end Another idea I had was to…
Rishi
  • 945
  • 2
  • 15
  • 23
0
votes
6 answers

Palindrome coding

I am trying to create a Palindrome tester in java using a method.. This is what I have so far. It is so close I just can't figure out why it won't say that it IS a palindrome and reverse it. System.out.println("Fun with Palindromes!!"); …
0
votes
7 answers

Palindrome Recursion Program

public static boolean palindrome(String input, int i, int j) { if (i >= j) return true; if (input.charAt(i) == input.charAt(j)) { i++; j--; palindrome(input, i, j); } else if (input.charAt(i) != input.charAt(j)) return…
Jason
  • 11
  • 1
  • 1
  • 3
0
votes
3 answers

detecting a palindrome without using reverse

I was thinking a way to create a function that detects a palindrome without using reverse... I thought I would be clever and do a condition where substring 0 to middle equals substring end to middle. I;ve found out that it only works on words with 3…
user2113651
  • 153
  • 2
  • 10
0
votes
1 answer

Ignore a letter in isPalindrome() method - Java

I am wondering how the following method could be modified to ignore a certain letter and have it as a wildcard when checking if a string is a palindrome... example: "wows", in this case the method should return false but "pat" , the 't' can be a…
choloboy7
  • 287
  • 2
  • 7
  • 19
0
votes
4 answers

Local variable not used

I am trying to make a test of whether an inputted word is a palindrome or not (the same spelled forward and backward). From what I can see it should work but Eclipse says "The value of the local variable isPalindrome is not used" , but it is used.…
Ferret9
  • 101
  • 1
  • 12
0
votes
0 answers

How to find shortes palindrome subsequence in the char[]

I am looking for the shortest palindrome in the char[]. How to do it beside taking every char and checking its surroundings chars what is giving O(n^2)?
Yoda
  • 17,363
  • 67
  • 204
  • 344
0
votes
2 answers

counting the number of palindromes in a range in python

I'm sort of new to python. I'm trying to go through a specific range of numbers and have python count all the palindromes in it and return them to me (total number count, not their sum). So it would count all the integers in this range and return…
user2172079
  • 11
  • 2
  • 6
0
votes
3 answers

need to derive a function for palindrome

I need to derive a function which takes a string and returns whether or not that string is a palindrome and my function should return True on strings which are palindromes if spaces aren’t considered (so it should say that ’a man a plan a canal…
Kuma
  • 123
  • 2
  • 5
  • 12
0
votes
1 answer

how to check compare if palindrome or not?

I don't know much of assembly language but I tried making this palindrome and it's quite hard. First I have to enter a string then show its original and reversed string then show if its a palindrome or not. I already figured out how to show the…
0
votes
3 answers

Having trouble with terminating code on a recessive palindrome method

I'm trying to write code that tells the user if a word they input is a palindrome or not. I am using a recursive method to reverse the word, but it isn't terminating correctly. The StackOverFlowError appears when I test it out. My terminating…
DaveMcFave
  • 232
  • 1
  • 4
  • 13
0
votes
0 answers

Get blank line after calling Palindrome function

So I have these two functions at the top of my program: string deletespaces(string sentence){ sentence.erase(std::remove(sentence.begin(), sentence.end(), ' '), sentence.end()); return sentence; } and string checkpalindrome(string…
user2093930
0
votes
3 answers

how to define a palindrome

I'm trying to define a palindrome. This is what I have so far but I'm not sure what is next can someone please help me. def palindrome(x): if x % 2==0: index1=0 index2=0 aString=str(x) number=len(aString) …
0
votes
8 answers

Checking a string for a palindrome (java) (rookie status)

I am trying to check to see if, entered a string, that the string is a palindrome if it is display something positive if not... something negative (invalid) I am currently getting the answer invalid both times (no matter what is entered) i'm not…
relativeLee
  • 39
  • 2
  • 7
0
votes
1 answer

How can I convert this C into MIPS?

int Reverse(int num) { int remainder = 0; int rev = 0; while ( num != 0) { remainder = num % 10; num = num /10; rev = rev * 10 + remainder; } return rev; } void Palindrome() { int num; cin…