Question: How do I solve this problem using Python programming? The core problem to be solved in the implementation of the Game of Life is how

How do I solve this problem using Python programming?  How do I solve this problem using Python programming? The core

The core problem to be solved in the implementation of the Game of Life is how to generate the next grid from the current grid. Your task is to write a function called nextGen which expects only one argument. That argument is a two-dimensional table (i.e., a list of lists) with m rows and n columns, representing the current grid. The elements of the table are either 0 (empty square) or 1 (occupied square). You may assume that all rows have the same number of elements. Given the current grid, nextGen computes and returns (but does not print) a new next grid (without altering the current grid) by applying the simple rules provided above. For example, given this initial grid: glider = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0. 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] your function should work like this: > > > x = nextGen (glider) > > > x [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0,0, 0], [0, 1, 0, 1,0, 0, 0], [0, 0, 1, 1, 0. 0. 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] > > > y = nextGen (x) > > > y [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0,1, 0, 1, 0. 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] > > > z nextGen (y) > > > z[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0,0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] > > > q = nextGen (z) > > > q [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0. 0. 0]]

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!