← 返回 snowflake 的题目列表Connect Four Game Evaluation
类型:online_judge
Determine Connect Four Game Outcome
Given a m * n board where players place pieces, determine if the current player wins, or if the game remains ongoing. A move is represented by coordinates (row, col) and a player's name player, which can be either a or b.
Write a function to determine if the current player has won the game or if it is still ongoing.
Winning condition: Four consecutive pieces horizontally, vertically, or diagonally for the same player.
Input:
board: A 2D list representing the board state, with positions occupied by a or b and others empty.
move: (row, col, player) indicating the current player's latest move.
Output:
Return the player's name (a or b) if the current player wins.
Return None if no player has won and the game is still ongoing.
Test Cases:
Input: board = [['a', 'b', ''], ['', '', ''], ['', '', '']], move = (0, 2, 'a'). Output: None.
Input: board = [['a', 'a', 'a', ''], ['b', 'b', 'b', ''], ['', '', '', '']], move = (0, 3, 'a'). Output: 'a'
Data Constraints:
m, n <= 10.
Example
Input
3 3
a b .
. . .
. . .
0 2 a