Tic-Tac-Toe Outcome

Start Timer

0:00:00

Upvote
1
Downvote
Save question
Mark as completed
View comments (2)

Write a Python function, check_tictactoe, that takes a 2D list representing a tic-tac-toe game board. This board will consist of 'X', 'O', and '-' (for an empty space). Your function should evaluate the state of the board and return one of four possible outcomes: 'X' if player X wins, 'O' if player O wins, 'Draw' if the game is a draw, or 'Not Finished' if the game is still ongoing.

The winning condition for the tic-tac-toe game is to have three of the same symbol in a row, column, or diagonal.

Example:

Input:

board = [
    ['X', 'O', 'X'],
    ['O', 'X', 'O'],
    ['O', '-', 'X']
]

Output:

def check_tictactoe(board) -> 'X'
.
.
.
.
.


Comments

Loading comments