Haskell How to generate all possible palindromes

how to generate all possible palindromes of the length n? the only chars ['a'..'z'] should be used palindrome n :: Integer -> [String] Even case Lets for simplicity first assume that n is even, later we can generalize the function. We can use recursi

Find a number that is both a prime number and a palindrome

I' fairly new to java. I have code in which a use inputs a number and the program check every number from 1 to n and outputs every number that is both a prime number and a palindrome. However my code doesn't output anything for some reason. There are

isPalindrome - Cancellation of the collection and the list

This is a homework lab for school. I am trying to reverse a LinkedList, and check if it is a palindrome (the same backwards and forwards). I saw similar questions online, but not many that help me with this. I have made programs that check for palind

Ruby the longest palindrome. Nested loop loops

I am writing some code to find the longest palindrome in a string. I want to start at index 0 and then push the increasing length of the substring to an array: ex: string = "ababa" [["a", "b"], ["a", "b",

Checking a table for palindromes

Instead of individually passing through the argument how can I loop through an array and check to see if each word is a palindrome? If it is I want to return the word if not i want to return a 0. var myArray = ['viicc', 'cecarar', 'honda']; function

Instance variables and a constructor?

So I have my code: import java.util.Scanner; public class PalindromeDriver { public static void main(String[] args) { String another = "y"; Scanner scan = new Scanner(System.in); PalindromeTester section = new PalindromeTester(); while (another.

Palindrome of a number - No log of the console

So I tried to write a code that finds the largest palindromic number from two (3 spaces long) multiplied numbers. Does my code work fine or are there no palindromes for this? function checkPalindrom(str) { return str === str.split('').reverse().join(

Test a Palindrome in Python

I now know there are better solutions for this, but I'm confused as to why I'm getting the result I am. import sys def isPalindrome(test): if len(test) == 1: return("Is a palindrome") else: if test[0] == test[-1]: isPalindrome(test[1:-1]) else:

The largest Palindrome in C

Really need help! This code should find a largest palindrome in a string. Which means if there are "abcdcba" and "cdc" in the same string, it should print "abcdcba" out since the length is longer. The function takes a string

I do not understand why I get this error on the other.

public static boolean isPalindrome(String word, int firstIndex, int lastIndex) { if(firstIndex>lastIndex) return true; else if(word.charAt(firstIndex)==(word.charAt(lastIndex))); { return true && isPalindrome(word, firstIndex+1, lastIndex-1); }

strcmp () returns 0 when comparing to unequal strings

In C, strcmp() function returns 0 if two strings are equal. When I give a code like this, char str[10] = "hello"; if(strcmp(str,strrev(str))==0) { printf("1"); } else printf("0"); This should print a 1 if its a palindromic st

Array index out of bound exception for java palindrome program

Why am i getting the array bound of exception? im beginner in programming. Please help me understand. I have tried to convert the string to char array and reverse the characters and convert the end result back to string and compare with the original

Can someone spot the error in this Java program?

This question already has an answer here: How do I compare strings in Java? 23 answers My program should check whether the input is a palindrome or not. The given program compiles and runs successfully. Program prints reverse string correctly but giv

Find palindromes in a painting

For this assignemnt, I think that I got it right, but when I submit it online, it doesn't list it as correct even though I checked with Eclipse. The prompt: Write a method isPalindrome that accepts an array of Strings as its argument and returns true

StringBuilder in reverse to change my initial variable?

I've recently started using Java, and I'm trying to get a short program that checks for palindromes in words or short sentences. I want to use StringBuilder for the reverse method. My idea was to have one variable from the user entry (that is convert

check if the number is a palindrome in C ++

/* david ballantyne 10/10/13 assesment lab 2 */ //Libraries #include <iostream> //Global Constants //Functioning Prototypes using namespace std; int main() { int n, num, digit, rev = 0; cout << "Enter a positive number"<<endl;

what is the anagram number that are string palindromes

What is the number of anagrams which are palindromes in a string? Example : string = "aaabbbb"; Possible anagram's which are palindromes "abbabba" , "bbaaabb" and "bababab". The problem here is the time, i have stri

Palindrome generator

Very inexperienced with python and programming in general. I'm trying to create a function that generates a list of palindromic numbers up to a specified limit. When I run the following code it returns an empty list []. Unsure why this is so. def pal

Palindrome Python Program Using Batteries

My assignment was to come up with a palindrome program in python. Which I did here def isPalindrome(word): for i in range(len(word)//2): if word[i] != word[-1-i]: return False return True print (isPalindrome("maam")) #returns TRUE print (isPalin

How to ignore punctuation and spaces in java?

import java.util.Scanner; public class Ex3 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.print("Please input a word: "); String Line = keyboard.nextLine(); boolean x = isReverse(Line); System.ou

How does the recursive isPalindrome function work?

I'm working on some introductory recursion problems and I have a clarifying question I'd like to get answered. The most nagging question I have is how is this recursion operating in the solved problem below? Despite having solved the problem, I'm jus

Why does not my program detect palindromes?

My assignment was to use the reference-based implementation of the ADT List and the array-based implementation of the ADT Stack in a program that has a user enter a string of lower-case letters. I was to go through the string and store each letter in