Determine Color of a Chessboard Square
给一个国际象棋的板子, 问某个个子的颜色.
1 2 3 4 5 6 7 |
class Solution { public boolean squareIsWhite(String c) { boolean res = (c.charAt(0) - 'a') % 2 == 0 ? false : true ; res = (c.charAt(1) - '1') % 2 == 0 ? res : !res; return res; } } |