- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3274.java
25 lines (22 loc) · 896 Bytes
/
_3274.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
packagecom.fishercoder.solutions.fourththousand;
importjava.util.HashSet;
importjava.util.Set;
publicclass_3274 {
publicstaticclassSolution1 {
publicbooleancheckTwoChessboards(Stringcoordinate1, Stringcoordinate2) {
returnisBlack(coordinate2) == isBlack(coordinate1);
}
privatebooleanisBlack(Stringcoordinate) {
Set<Character> blackColsWithOddRows = newHashSet<>();
blackColsWithOddRows.add('a');
blackColsWithOddRows.add('c');
blackColsWithOddRows.add('e');
blackColsWithOddRows.add('g');
if (blackColsWithOddRows.contains(coordinate.charAt(0))) {
returnCharacter.getNumericValue(coordinate.charAt(1)) % 2 == 1;
} else {
returnCharacter.getNumericValue(coordinate.charAt(1)) % 2 == 0;
}
}
}
}