Chewy is prototyping a Tic Tac Toe feature for a customer-facing game experience. Given the board size and the moves played in order, determine whether player A wins, player B wins, the game ends in a draw, or play is still pending.
The board is an n x n grid. Players alternate turns, with A moving first. A player wins when all cells in any row, column, main diagonal, or anti-diagonal belong to that player. The input contains only valid moves, and no moves occur after the game has ended.
Implement tic_tac_toe(n, moves), where n is an integer and moves is a list of coordinate pairs [row, column]. Return one of the strings "A", "B", "Draw", or "Pending".
Do not allocate an n x n board. Track only the information needed to determine whether the latest move completes a winning line.
def tic_tac_toe(n, moves):