Question: Please do the following by using Python: Note: count_isolated (grid): Given grid as a 2D list of characters representing a two-dimensional board Assume that we

Please do the following by using Python:

Please do the following by using Python: Note: count_isolated (grid): Given grid

Note:

as a 2D list of characters representing a two-dimensional board Assume that

count_isolated (grid): Given grid as a 2D list of characters representing a two-dimensional board Assume that we use string containing a single period ('. ') to represent an empty cell. One cell can have up to eight neighbors, which are cells adjacent to it either horizontally, vertically, or diagonally. A cell is isolated if all its neighbor cells are empty. This function counts and returns how many non- empty cells in the board are isolated. Make sure to check the horizonal, vertical, and diagonal neighbors o Assume: grid is a list of lists of characters o Assume: all rows in the grid have the same number of columns o Restrictions: no extra restrictions o Examples: # one non-empty cell; all its # neighbors are empty grid1: 3x3 board, one non-empty cell count_isolated (grid1) # all cells empty grid2: 3x3 board, all cells empty count_isolated(grid2)-* # cell A has cell B as its diagonal neighbor; # cell C has cell B as its vertical neighbor; # cell B has two non-empty neighbors (A and C) grid3: 3x4 board, (three rows, four columns). Four non-empty cells, but only one (cell X) is isolated X.B. count_isolated (grid3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!