| 7 | import java.util.regex.*; |
| 8 | |
| 9 | public class FunnyString { |
| 10 | |
| 11 | // Complete the funnyString function below. |
| 12 | static String funnyString(String s) { |
| 13 | StringBuilder str = new StringBuilder(s); |
| 14 | String reverse = str.reverse().toString(); |
| 15 | for(int i=0;i<s.length()-1;i++){ |
| 16 | if(Math.abs((int)s.charAt(i) - (int)s.charAt(i+1)) != Math.abs((int)reverse.charAt(i) - (int)reverse.charAt(i+1))){ |
| 17 | return "Not Funny"; |
| 18 | } |
| 19 | } |
| 20 | return "Funny"; |
| 21 | |
| 22 | } |
| 23 | |
| 24 | private static final Scanner scanner = new Scanner(System.in); |
| 25 | |
| 26 | public static void main(String[] args) throws IOException { |
| 27 | BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); |
| 28 | |
| 29 | int q = scanner.nextInt(); |
| 30 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?"); |
| 31 | |
| 32 | for (int qItr = 0; qItr < q; qItr++) { |
| 33 | String s = scanner.nextLine(); |
| 34 | |
| 35 | String result = funnyString(s); |
| 36 | |
| 37 | bufferedWriter.write(result); |
| 38 | bufferedWriter.newLine(); |
| 39 | } |
| 40 | |
| 41 | bufferedWriter.close(); |
| 42 | |
| 43 | scanner.close(); |
| 44 | } |
| 45 | } |
nothing calls this directly
no outgoing calls
no test coverage detected