Wise. Energy uses a configurable grid game for testing energy-planning strategies. Given an n x n board, two players alternate placing marks, and a player wins by forming x contiguous marks horizontally, vertically, or diagonally.
Implement a function that processes the moves in order and returns the first winner. Return "A" or "B" when that player first forms a winning line, otherwise return "Draw" after all supplied moves are processed.
Implement tic_tac_toe(n, x, moves), where n and x are integers and moves is a list of [row, column] pairs. Rows and columns are zero-indexed. Player A makes moves at even indices, and player B makes moves at odd indices. Every move is valid, targets an empty cell, and the game stops immediately after a winning move. The function returns a string.
A winning line may extend in either direction from the latest move, but all x cells must belong to the same player and share one of four orientations: horizontal, vertical, diagonal, or anti-diagonal.
def tic_tac_toe(n, x, moves):