-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathques26.java
32 lines (23 loc) · 978 Bytes
/
ques26.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
import java.util.*;
//Check if Two Chessboard Squares Have the Same Color
//LEETCODE LIKE --> https://leetcode.com/problems/check-if-two-chessboard-squares-have-the-same-color/description/
//CONTEST WEEKLY 413
public class ques26 {
public static String result(String s) {
int n = (int) s.charAt(0);
int j = (int) s.charAt(1);
return (((n % 2 == 0 && j % 2 == 0) || (n % 2 != 0 && j % 2 != 0))) ? "black" : "white";
}
public static boolean checkTwoChessboards(String coordinate1, String coordinate2) {
String k = result(coordinate1);
String l = result(coordinate2);
return k.equals(l);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String coordinate1 = sc.next();
String coordinate2 = sc.next();
boolean result = checkTwoChessboards(coordinate1, coordinate2);
System.out.println(result);
}
}