Time for an 2014 update…

This commit is contained in:
Ingy döt Net 2014-01-17 05:32:22 +00:00
parent 372c577f83
commit 09687c4926
2520 changed files with 34227 additions and 7318 deletions

View file

@ -1,4 +1,4 @@
public static boolean pali(String testMe){
StringBuilder sb = new StringBuilder(testMe);
return testMe.equalsIgnoreCase(sb.reverse().toString());
return testMe.equals(sb.reverse().toString());
}

View file

@ -2,7 +2,7 @@ public static boolean rPali(String testMe){
if(testMe.length()<=1){
return true;
}
if(!(testMe.charAt(0)+"").equalsIgnoreCase(testMe.charAt(testMe.length()-1)+"")){
if(!(testMe.charAt(0)+"").equals(testMe.charAt(testMe.length()-1)+"")){
return false;
}
return rPali(testMe.substring(1, testMe.length()-1));

View file

@ -1,3 +1,14 @@
public static boolean pali(String testMe){
return testMe.matches("|(?:(.)(?<=(?=^.*?(\\1\\2?)$).*))+(?<=(?=^\\2$).*)");
public static boolean rPali(String testMe){
int strLen = testMe.length();
return rPaliHelp(testMe, strLen-1, strLen/2, 0);
}
public static boolean rPaliHelp(String testMe, int strLen, int testLen, int index){
if(index > testLen){
return true;
}
if(testMe.charAt(index) != testMe.charAt(strLen-index)){
return false;
}
return rPaliHelp(testMe, strLen, testLen, index + 1);
}

View file

@ -0,0 +1,3 @@
public static boolean pali(String testMe){
return testMe.matches("|(?:(.)(?<=(?=^.*?(\\1\\2?)$).*))+(?<=(?=^\\2$).*)");
}