Back to problems

Four-in-a-row Game

Algorithm · Snowflake · Medium

Implement the function canPlayWin(board, x, y, player). You are given a 2D array board where each cell contains one of "a", "b", or an empty string "". The board depicts the state before any winning line of four exists. The intended move is expressed by the row index x, column index y, and the piece player (either "a" or "b"). The cell at (x, y) is guaranteed to be empty initially. After placing the player's piece in that cell, check whether this single action produces a…

Checking your access…