-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunnyString.java
28 lines (26 loc) · 915 Bytes
/
FunnyString.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class FunnyString
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int testCases = Integer.parseInt(sc.nextLine());
boolean isFunny = true;
for(int i = 0;i<testCases;i++)
{
String str = sc.nextLine();
for(int j=0 ; j<str.length()-1 ; j++ )
{
int val1 = Math.abs(Character.getNumericValue(str.charAt(str.length()-2-j))-Character.getNumericValue(str.charAt(str.length()-1-j)));
int val2 = Math.abs(Character.getNumericValue(str.charAt(j+1))-Character.getNumericValue(str.charAt(j)));
if(val1!=val2)
{
isFunny = false;
break;
}
}
System.out.println(isFunny?"Funny":"Not Funny");
isFunny = true;
}
}
}