Wise runs its Software Engineer pair-programming round on a deliberately small problem so the interviewer can watch how you structure code, handle invalid input, and extend a design when the rules change. The classic version is Tic-Tac-Toe; the follow-ups make the board n x n and the winning run k in a row.
Implement play_tic_tac_toe(n, k, moves), which replays a list of moves on an empty n x n board and returns the state of the game.
Rules
X always moves first and the two players alternate. A move is [row, col], zero-indexed.k of their marks consecutively in a row, a column, or either diagonal direction, anywhere on the board.Return value
Return exactly one of these strings:
"X wins" or "O wins" if a player has won."Draw" if every cell is filled and nobody has won."In progress" otherwise, including when moves is empty."Invalid move: out of bounds" if a move lies outside the board."Invalid move: cell occupied" if the target cell already holds a mark."Invalid move: game over" if a move is made after the game has been won.Design the solution so that the board size and winning length are parameters, not constants, and so that the win check does not rescan the whole board on every move.
def play_tic_tac_toe(n, k, moves):
def play_tic_tac_toe(n, k, moves):