-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreePart1.java
36 lines (32 loc) · 1017 Bytes
/
ThreePart1.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
class ThreePart1 {
public static int getPrio(char c) {
if (c == Character.toUpperCase(c)) {
return c - 'A' + 27;
} else {
return c - 'a' + 1;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int total = 0;
while (line != null) {
char target = 0;
String p1 = line.substring(0, (line.length()/2));
String p2 = line.substring((line.length()/2));
for (char e: p1.toCharArray()) {
if (p2.indexOf(e) != -1) {
target = e;
break;
}
}
total += getPrio(target);
line = br.readLine();
}
System.out.println(total);
}
}