मध्यम 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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।

दूसरों से सीखें

समुदाय समाधान

अभी तक कोई प्रकाशित समाधान नहीं। पहला साझा करने के लिए इस चुनौती को हल करें।