I want some Logical algorithm to get all possible combination of given string except the palinadromes.
Like Input is: ABC
OutPut: A,B,C,AB,AC,BC,ABC,ACB,BCA,BAC
It can't contain CBA,CAB as it already has ABC,BAC i.e reverse of those.
I want to get it done by boolean logic and but it is no where near, I guess.
public static void myComb(String s)
{
int num=s.length()+1;
boolean b[]=new boolean[num];
for(int i=(int)(java.lang.Math.pow(2, num)-4);i>0;i-=2)
{
String output=new String();
for(int j=1;j<num;j++)
if((i & (1<<j))!=0)
{
System.out.print(s.substring(j-1,j));
//output.concat(s.substring(j,j+1));
}
System.out.println("");
}
}