You are viewing a single comment's thread. Return to all comments →
Java submition
public static boolean isFunny(String asx) { char[] chars = asx.toCharArray(); char[] chars2 = new StringBuilder(asx).reverse().toString().toCharArray(); for (int i = 1; i < asx.length(); i++) { if (Math.abs((int) chars[i] - (int) chars[i - 1]) != Math.abs((int) chars2[i] - (int) chars2[i - 1])) { return false; } } return true; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); in.nextLine(); // Discard '\n' for(int a0 = 0; a0 <t; a0++){ String n = in.nextLine().trim(); String result = (isFunny(n)==true) ? "Funny" : "Not Funny"; System.out.println(result); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Funny String
You are viewing a single comment's thread. Return to all comments →
Java submition
}