Skip to content

Commit b575e5c

Browse files
committed
issue #30 A Chessboard Game java
1 parent d41b348 commit b575e5c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package hackerrank;
2+
3+
public class AChessboardGame {
4+
5+
static String chessboardGame(int x, int y) {
6+
for (int i = 0; i < 2; i++) {
7+
if (((x - 1) / 2) % 2 == 0 && ((y - 1) / 2) % 2 == 0) {
8+
return "Second";
9+
}
10+
}
11+
return "First";
12+
}
13+
14+
public static void main(String[] args) {
15+
System.out.println(chessboardGame(5, 2) + ", ans: Second");
16+
System.out.println(chessboardGame(5, 3) + ", ans: First");
17+
System.out.println(chessboardGame(8, 8) + ", ans: First");
18+
}
19+
20+
}

0 commit comments

Comments
 (0)