# palindrome array problem

Generate (write the code) and save in an array Palidrome all the 5 letter words using {a, b, c}

Write the code and show the execution for:

a.) Count the number of palindromes in this set.

b.) Print out all the palindromes where a letter appears more than twice.

```   Examples a a b a a ;  b b b b b;  c a c a c;   a b b b a   etc.
```

c.) Print out all the palindromes where a letter appears no more than twice.

Examples a b c b a; a c b c a etc. October 10, 2012 at 12:57 PM

Here is a code that displays all the 5 letter words using {a, b, c}and display the palindromes from them.

```public class GeneratePalindromes{
static boolean isPalindrome(String s){
int left = 0;
int right = s.length() - 1;
while (left < right){
if (s.charAt(left) != s.charAt(right))
return false;
left++;
right--;
}
return true;
}
public static void main(String[] args){
char[] chars = "abc".toCharArray();
int len = 5;
System.out.println("Display all the words: ");
iterate(chars, len, new char[len], 0);
System.out.println("Display all the palindromes: ");
checkPalin(chars, len, new char[len], 0);
}
public static void iterate(char[] chars, int len, char[] build, int pos) {
if (pos == len) {
String word = new String(build);
System.out.println(word);
return;
}
for(int i = 0; i < chars.length; i++) {
build[pos] = chars[i];
iterate(chars, len, build, pos + 1);
}
}
public static void checkPalin(char[] chars, int len, char[] build, int pos) {
if(pos == len) {
String word = new String(build);
if(isPalindrome(word)){
System.out.println(word);
}
return;
}
for(int i = 0; i < chars.length; i++) {
build[pos] = chars[i];
checkPalin(chars, len, build, pos + 1);
}
}
}
``` October 10, 2012 at 7:22 PM

Thank you so much!

palindrome array problem
palindrome array problem  I'm having trouble figuring this assignment out. Can someone please help me? Generate (write the code) and save in an array Palidrome all the 5 letter words using {a, b, c} Write the code
array problem
array problem  An integer array a has 19 elements. What is the value of the middle element after the following codes is executed? int i, j,n=19; for (i=0; i for(i=0, j=n-1; i<=j; i++, j--) a[(i+j)/1] -= (a[i]+a[j])/2
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check
Array /string based problem....
Array /string based problem....  thanx to help me.but again a problem... solve this problem also as soon as possible..... import java.util.*; public class... or char"); char[] array = new char; for(int i=0;i<5;i++){ char ch
string array based problem
string array based problem  R/sir, firstly thanks... sorted value: 11 12 13 3 this is the problem here...... import java.util.*; public... string: "); String[] array = new String; for(int i=0;i<5;i++){ array[i
Palindrome
Palindrome  program to verify palindrome
problem in array if condtion
problem in array if condtion  sir i have prblem in js...i have array... = new Array(); arr = new Array("-select-"); arr = new Array("Maharashtra","Karnataka","Kerela","Rajashthan"); arr = new Array("Texas","New York","Florida
java array problem
java array problem  suppose i have an array a[] at a i have value 5,7 the thing is that i want to assign the value of array a=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
palindrome
palindrome  write a program to print palindrome numbers between 500 to 700
palindrome
palindrome  how to write in string of palindrome?   import... is palindrome"); } else{ System.out.println("String is not palindrome
palindrome
palindrome  how to write in string of palindrome   import... is palindrome"); } else{ System.out.println("String is not palindrome
PALINDROME
PALINDROME  how to find palindrome of a number WITHOUT using a string... == reversedNumber){ System.out.print("Number is palindrome!"); } else{ System.out.println("Number is not palindrome!"); } } catch(Exception e){ System.out.println(e
java palindrome
java palindrome  sir i need java program to print 1)integer palindrome 2)string palindrome
complete the code (palindrome) - Java Beginners
complete the code (palindrome)  Write a program that checks if a word is palindrome. A word is said to be palindrome if it reads the same forward...: noon noon is a palindrome. Enter a word: moon moon is not a palindrome
prime palindrome
prime palindrome  Hi I want to write a program in pascal that ask a user to input a number, the program then list all the prime number that are palindrome below the number entered. thks
prime palindrome
prime palindrome  Hi I want to write a program that ask a user to input a number, the program then list all the prime numbers that are palindrome below the number entered. In pascal language Thanks
To check a palindrome number?
To check a palindrome number?  program to check a number is palindrome or not using recursion?(wihout converting to string
ModuleNotFoundError: No module named 'palindrome'
ModuleNotFoundError: No module named 'palindrome'  Hi, My Python... 'palindrome' How to remove the ModuleNotFoundError: No module named 'palindrome' error? Thanks   Hi, In your python environment you
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php \$yes = array('Hello', 'World'); echo is_array(\$yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php \$yes = array('Hello', 'World'); echo is_array(\$yes) ? 'Array
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q