-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1607AdvancingLetters.java
More file actions
50 lines (43 loc) · 1.13 KB
/
URI1607AdvancingLetters.java
File metadata and controls
50 lines (43 loc) · 1.13 KB
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
50
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1607">Advancing
* Letters</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1607AdvancingLetters {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int T = readInt(), changes, l1, l2;
char[] w1, w2;
String[] P;
while (T-- > 0) {
P = read().split("\\s");
w1 = P[0].toLowerCase().toCharArray();
w2 = P[1].toLowerCase().toCharArray();
changes = 0;
for (int i = 0; i < w1.length; i++) {
l1 = (int) w1[i];
l2 = (int) w2[i];
if (l2 > l1) {
changes += l2 - l1;
} else if(l1 > l2){
changes += 26 - l1 + l2;
}
}
out.println(changes);
}
out.close();
}
private static String read() throws IOException {
return in.readLine();
}
private static int readInt() throws IOException {
return Integer.parseInt(in.readLine());
}
}