-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeLoveLetterMystery.java
50 lines (42 loc) · 1007 Bytes
/
theLoveLetterMystery.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int k;
String a[]=new String[20];
for(k=0;k<=n;k++)
a[k]=sc.nextLine();
for(k=1;k<=n;k++)
{
int count=0;
int i=0;
int len=a[k].length();
int j=len-1;
while(i<j)
{
int i1=(int)a[k].charAt(i);
int j1=(int)a[k].charAt(j);
if(i1==j1)
{
}
if(i1>j1)
{
count=count+(i1-j1);
}
if(i1<j1)
{
count=count+(j1-i1);
}
i++;
j--;
}
System.out.println(count);
}
}
}