-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeCards.java
46 lines (32 loc) · 1.06 KB
/
CodeCards.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
import java.util.Scanner;
public class CodeCards {
public static boolean incode(char ch) {
return ch == 'c' || ch == 'o' || ch == 'd' || ch == 'e';
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while (t-- > 0) {
String s1 = scn.next();
String s2 = scn.next();
boolean flag = true;
int count = 0;
for (int i = 0; i < s1.length(); i++) {
if (s1.charAt(i) == s2.charAt(i)) {
continue;
}
if (s1.charAt(i) == '$' && incode(s2.charAt(i))) {
count++;
continue;
}
if (s2.charAt(i) == '$' && incode(s1.charAt(i))) {
count++;
continue;
}
flag = false;
break;
}
System.out.println(flag ? count : "-1");
}
}
}