Средне Решено: 0 Процент решений: 0%

Tic-Tac-Toe Winner

Decide the result of a tic-tac-toe board.

Условие

A 3×3 board is given as three strings of X, O and . (empty). A player wins with three of their marks in a row, column or diagonal. Boards never have two winners.

Implement tic_tac_toe_winner(board).

Input

board: Three rows of three characters each.

Output

Return "X" or "O" for the winner, "Draw" if the board is full with no winner, or "Pending" if empty cells remain and nobody has won.

Ограничения

board has exactly 3 rows of length 3

Примеры

Пример 1
Ввод:
board = ["XOX", ".X.", "O.X"]

Ожидаемый вывод:
expected = "X"
Ввод:
std::vector<std::string> board = {"XOX", ".X.", "O.X"};

Ожидаемый вывод:
std::string expected = "X";
Ввод:
string[] board = new string[] {"XOX", ".X.", "O.X"};

Ожидаемый вывод:
string expected = "X";

Пояснение

X holds the diagonal from top-left to bottom-right, so X wins.

Пример 2
Ввод:
board = ["XOX", "XOO", "OXX"]

Ожидаемый вывод:
expected = "Draw"
Ввод:
std::vector<std::string> board = {"XOX", "XOO", "OXX"};

Ожидаемый вывод:
std::string expected = "Draw";
Ввод:
string[] board = new string[] {"XOX", "XOO", "OXX"};

Ожидаемый вывод:
string expected = "Draw";

Пояснение

The board is full and no line has three of a kind: Draw.

Ссылки

Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.