Does This Connect Four Move Win?
A Connect Four board is a grid of numbers: 0 empty, 1 and 2 the two players. A piece was just placed at (row, col). Return whether it completed a line of four or more of that player's pieces — horizontally, vertically or on either diagonal.
board = [[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[2, 2, 0, 0, 0],
[1, 1, 1, 1, 2]]
isWinningMove(board, 3, 3) -> true
isWinningMove(board, 2, 1) -> falseHints
Hint 1
Do not rescan the board. For each of the four directions, count the matching pieces outward from the move both ways; the run length is 1 plus the two counts.
Hint 2
A run of five or more also wins — compare with >= 4, not == 4.