Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use PYTHON only and follow all the following instructions carefully. Than

ID: 3596390 • Letter: P

Question

Please use PYTHON only and follow all the following instructions carefully. Thank you

Requirements

Background info (for your reference):

Problem statements:

Please make sure that it can pass all the test cases as follows: https://repl.it/Mvr6

Restrictions no modules may be imported. Allowed basic statements, variables, operators, del, indexing, slicing, in, are all allowed any form of control flow we've covered is allowed (if/else, loops, etc) only these built-in functions: range(), len(), int), str), list), abs () only these built-in methods: s.split), s.join(), s.pop(), xs.append), xs.extend), xs.insert(), s.format() calling other functions of the project (and your own helper functions). Please do this! Hint In our solution, we only used range, len, in, abs, .append(), .join(), .split(), and list() Remember: your grade is significantly based on passing test cases- try to completely finish individual functions before moving on. The easiest way to implement many functions is to call the earlier/easier functions, so it'll pay off to complete functions before moving on. Don't let yourself be "almost done" with a function, but miss all the tests!

Explanation / Answer


# create a copy of board
def get_copy_of_board(board):
board_copy = []
for row in board:
newRow = []
for col in row:
newRow.append(col)
board_copy.append(newRow)
return board_copy

def winning_move(board,color):
# if board is not pending then there cant be any winning move.
if check_winner(board) != "pending":
return None
  
(row, col) = get_size(board)
  
# for each column see if we add one entry and then check if we found a winner, if yes then there is winning move and hence we will return column index
for j in range(col):
board_copy = get_copy_of_board(board)
if place_one(board_copy, j, color):
if check_winner(board_copy) == color:
return j
# if no winning index return None
return None

# copy pastable code link: https://paste.ee/p/DeL4b