// Topcoder SRM 564 DIV 2, L1: FauxPalindromes
import java.util.*;
class TopcoderSolution {
public static void main(String[] args) {
FauxPalindromes obj = new FauxPalindromes();
System.out.println(
// obj.numPairs(numbers)
);
}
}
// change to public before submit
public class FauxPalindromes {
public String classifyIt(String word) {
String rev = (new StringBuffer(word)).reverse().toString();
if (word.equals(rev))
return "PALINDROME";
String word2 = word.substring(0, 1);
for (int i = 1; i < word.length(); i++) {
if (word.charAt(i) == word.charAt(i - 1))
continue;
else
word2 = word2 + String.valueOf(word.charAt(i));
}
if (word2.equals((new StringBuffer(word2)).reverse().toString()))
return "FAUX";
return "NOT EVEN FAUX";
}
}
No comments:
Post a Comment