Einfach 0 gelöst 0% Erfolgsquote

Chess Square Color

Determine the color of a square on an 8 by 8 board.

Use a board whose top-left square is white. Rows and columns start at 0 at the top left. Adjacent squares alternate colors. Return empty text for a position outside the board.

Implement chess_square_color(column, row).

Input

column: The column, counted from the left starting at 0.

row: The row, counted from the top starting at 0.

Output

Return white, black, or an empty string for invalid coordinates.

Einschränkungen

−10 ≤ column, row ≤ 20. Valid board coordinates are 0 through 7.

Beispiele

Beispiel 1
Eingabe:
row = 3
column = 2

Erwartete Ausgabe:
expected = "black"
Eingabe:
long long row = 3;
long long column = 2;

Erwartete Ausgabe:
std::string expected = "black";
Eingabe:
long row = 3;
long column = 2;

Erwartete Ausgabe:
string expected = "black";

Erläuterung

Five steps from the white corner change color an odd number of times.

Beispiel 2
Eingabe:
row = 0
column = 8

Erwartete Ausgabe:
expected = ""
Eingabe:
long long row = 0;
long long column = 8;

Erwartete Ausgabe:
std::string expected = "";
Eingabe:
long row = 0;
long column = 8;

Erwartete Ausgabe:
string expected = "";

Erläuterung

Column 8 is outside the valid range 0 through 7.

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.