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
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
So this was a problem statement from CodeLeet to find the Longest Palindromic Substring. In the codeleet interface this solution works: class Solution { public: string longestPalindrome(string s) { int len = s.size(); int P[len][len]; memset(P, 0, le
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
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",
I want to try to solve the "PALINDROME" problem using queue and stack i am using the corresponding methods like push/pop and offer()[or add()]/poll() for inserting and removing the element from stack and queue respectively.But it seems enqueing
Trying to check for palindromes. I've checked other answers but none included punctuation & spaces. "never odd or even" and "A man, a plan, a canal. Panama" Should return true but they don't. function palindrome(str) { if(str.repla
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
I like many of the features in Swift, but using manipulating strings are still a big pain in the ass. func checkPalindrome(word: String) -> Bool { print(word) if word == "" { return true } else { if word.characters.first == word.characters.la
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.
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(
I was working on this for a class assignment, and I cannot for the life of me get it to compile. I keep getting this error: CPT236PalindromeCheckMethod.java:52: error: reached end of file while parsing } ^ 1 error I have tried adding, removing, and c
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:
I want to find the longest palindrome inside a char array. This is what I tried: #include <iostream> #include <conio.h> using namespace std; bool valid(int s, int d, int n) { return s >= 0 && d < n; } char *calcPal(char cuv[], in
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
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); }
This is how to get palindrome using a reverse operation. predicates palin(list) findrev(list,list,list) compare(list,list) clauses palin(List1):- findrev(List1,[],List2), compare(List1,List2). findrev([],List1,List1). findrev([X|Tail],List1,List2):-
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
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
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
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
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
/* 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 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
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
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
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
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
package testing.project; public class PalindromeThreeDigits { public static void main(String[] args) { int value = 0; for(int i = 100;i <=999;i++) { for(int j = i;j <=999;j++) { int value1 = i * j; StringBuilder sb1 = new StringBuilder(""+
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