-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperScissors.java
More file actions
36 lines (31 loc) · 1.04 KB
/
Copy pathRockPaperScissors.java
File metadata and controls
36 lines (31 loc) · 1.04 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
import java.util.Scanner;
public class RockPaperScissors {
public String solution(int n, int[] arr1, int[] arr2){
StringBuilder answer = new StringBuilder();
for(int i=0;i<n;i++){
if(arr1[i] == arr2[i])
answer.append("D");
else if ((arr1[i] ==1 && arr2[i] == 3) ||(arr1[i] ==2 && arr2[i] == 1) || (arr1[i] ==3 && arr2[i] == 2))
answer.append("A");
else
answer.append("B");
}
return answer.toString();
}
public static void main(String[] args) {
RockPaperScissors t = new RockPaperScissors();
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] arr1 = new int[n];
int[] arr2 = new int[n];
for(int i=0; i< n ;i++){
arr1[i] = scanner.nextInt();
}
for(int i=0; i< n ;i++){
arr2[i] = scanner.nextInt();
}
for (char c : t.solution(n, arr1, arr2).toCharArray()) {
System.out.println(c);
}
}
}