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
3 answers

How can I create a pallindrome code in JavaScript?

So I am trying to create a code for palindrome this is how I tried. Is there another or better way of doing it? But now it only shows that if the first value is equal or not and shows true or false? var inpo= prompt("Please enter to check if…
-1
votes
1 answer

where am I going wrong with this function?

So i'm supposed to Move all palindrome numbers from mValues vector to mPalindromes vector and the only hints I was given was a pseudo code: // iterate through the main values vector // if the value is a palindrome // add…
Neteroh
  • 7
  • 4
-1
votes
1 answer

How is my method not working in Palindrome question?

Here is my question. It's asking to return true if int x is a palindrome otherwise return false: public class Palindrome { public boolean isPalindrome(int x) { StringBuilder number = new StringBuilder(Integer.toString(x)); …
Thatdude22
  • 57
  • 9
-1
votes
3 answers

I'm not getting output for my palindrome program in Java

import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int i; String A=sc.next(); String B= ""; /* Enter your code…
-1
votes
2 answers

Why is my Python palindrome-function failing?

def is_palindrome(input_string): # We'll create two strings, to compare them if input_string[0:] == input_string[-1:]: return True else: return False expected output is below: print(is_palindrome("Never Odd or Even")) # Should be…
younggbon
  • 19
  • 1
  • 3
-1
votes
2 answers

Why Python Palindrome fail

import sys for line in sys.stdin: if line == line[::-1]: print('true') else : print('false') I type abba but got false I print line[::-1] out it was 'abba' why result is false?
luk
  • 75
  • 4
  • 15
-1
votes
3 answers

Why is this c# Palindrome Program not working?

using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Palindrome { class Program { static void Main(string[] args) { string filePath =…
Marvin
  • 65
  • 1
  • 8
-1
votes
3 answers

Unable to run Palindrome program in Java

Here's my Java code to find a palindrome of a string. It shows o/p as "Palindrome" even though the i/p that I've entered is not. Can anyone please help. String a = sc.next(); char b[] = a.toCharArray(); char d[] = b; int size = a.length(); int…
-1
votes
2 answers

Asking user to enter specific number of strings then adding each string to array?

New to java. I need to ask the user the number of strings (consisting only of upper and lowercase letters, spaces, and numbers) they want to input. These strings need to be stored in an array. Then I created a boolean method to be able to tell if…
kak23
  • 1
  • 4
-1
votes
1 answer

Longest palindrome (dynamic programming) code fails with time-out for large inputs. How to improve it?

I am learning to solve dynamic programming problems on LeetCode recently. The problem in hand is to find the longest palindrome in any given string. My code works well for small sized input strings. But fails for very large size inputs. Looking…
Arun Kumar
  • 634
  • 2
  • 12
  • 26
-1
votes
2 answers

Print couple of Palindromes out of a user input

I would like to print a few words out of a user input, for example for that sentence: " we love mom and dad" the program will print "mom dad" I have no idea how to print those words. just the chars m and d. Much Appreciate ! here is my code: …
Tal Ouzan
  • 75
  • 1
  • 5
-1
votes
2 answers

Date Palindrome finder is not functioning correctly (Java)

I'm quite new to programming, and I was trying to find the next nearest palindromic date that will occur and I wrote the following code. But the problem that I'm facing is that it keeps on printing out the same exact thing again and again rather…
ft1
  • 21
  • 4
-1
votes
3 answers

Trying to test if the given string is a palindrome by words

Hi i'm trying to achieve this output. I'm trying to see if the string is a palindrome by comparing the first word and the last word, second word and the second last word. King, are you glad you are king is a palindrome (or that's the outcome i'm…
user12255294
-1
votes
1 answer

C# Console.WriteLine()

So, I wrote this code to run string values in a json file and determine if it is a palindrome or not. I am having trouble displaying the results in the console correctly. My Console.WriteLine is the issue (i think). It displays the true/false…
idkidk
  • 61
  • 5
-1
votes
1 answer

C# Palindrome Test

I need to create a IsPalindrome function where it will determine if a provided string is a palindrome. Alphanumeric chars will be considered when evaluating whether or not the string is a palindrome. With this said, I am having trouble trying to…
idkidk
  • 61
  • 5