PROBLEM 94
Hard

Chessboard Color

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#94

Given chessboard cell `x y` from 1 to 8. Treat (1,1) as black. Print `BLACK` or `WHITE`.

EXAMPLE

Example

Input
1 2
Output
WHITE

LIMITS

Constraints

1 ≤ x,y ≤ 8
📖
LEARN Theory for this problem
+

### Chessboard Color

`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.

💡
NEED HELP? Hints
+

['Translate every case from the statement into a boolean condition before writing branches.', 'After each iteration, it should be clear what has already been accumulated and what remains to be processed.']

ANSWER Solution
+
const fs = require('fs');

const [x, y] = fs
    .readFileSync(0, 'utf8')
    .trim()
    .split(/\s+/)
    .map(Number);

const isBlack = (x + y) % 2 === 0;

console.log(isBlack ? 'BLACK' : 'WHITE');