Question: Using Python The Tic-Tac-Toe is represented by a 2D list where X=1 and O=2, create a function named winInRow. The function will take 3 parameters:
Using Python
The Tic-Tac-Toe is represented by a 2D list where X=1 and O=2, create a function named winInRow.
The function will take 3 parameters: 1. a two-dimensional list that holds a representation of the board game-state 2. a number for a specific row to look in 3. the piece type of one of the players
This function should return True if there are 3 pieces side by side in the indicated row of the indicated piece type. Remember that we have the possibility of rows of length 3 and of length 4. You will have to create an implementation that finds 3 in a row in both of these situations. You cant just find the total number of pieces of the same type in the row. In a row of length 4 there may be 3 pieces with an EMPTY or opponent piece in between them which prevent them from being 3 in a row. There are many ways to accomplish this function, the key challenges are that in some games rows will be 3 cells long, in others 4 cells long, and that there may be blanks or opponent pieces separating the piece type being checked. The second function has many similarities to you first one. Instead of keeping your row the same and looking in different column indices you will keep the column the same and change your row indices.
Thanks in advance!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
