Given a grid with n rows and m columns of binary integers, 0 or 1, and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a grid with n rows and m columns of binary integers, 0 or 1, and a set of rules, simulate k turns of the game on this grid. The given grid denotes the initial configuration for the game, where grid[i] [] = 1 denotes that cell in the throw and th column is alive, and grid[i] = 0 denotes that this cell is dead. Two cells are neighbors when they share at least one common corner, thus each cell has at most 8 neighbors, as shown in the picture below: There is a list of 9 rules indexed from 0 to 8, each rule having a value of either 'alive' or 'dead'. A single rule, let's say rule i, specifies what happens to the cells with exactly i alive neighbors. In each turn, the new value of a cell is determined by counting the number of "alive' neighbors and applying the rule at index corresponding to the count. As an example, consider a rule set where rules at indices 3 and 5 are 'alive'. All of the other rules are dead. The following shows the process for two turns starting with the grid given in turn 0: Turn 0 Grid 0110 1100 White cell with 8 neighbors 1100 0110 0110 1100 Live neighbors for each cell 3321 2331 2331 3321 The "Live neighbors for each cell" grid at turn 7 contains the number of adjoining live cells at each grid position for turn 0. It is used to create the new grid state for turn 7. At each cell with a value of 3 or 5, the David Paul Th X top Washington Post: B... ⠀⠀⠀ Python 3 TTTT AWNINGSAWNHO 1 >#!/bin/python3... 10 1 11 # 14 15 16 17 18 19 # 20 (5) Alan Watts-Outw x NA 22 23 24 > if 21 def gridGame (grid, k, rules): #Write your code here name Test Results The New York Time... DeviantArt-Discov... 12 # Complete the 'gridGame function below. 13 # # The function is expected to return a 2D_INTEGER ARRAY. # The function accepts following parameters: # 1. 2D INTEGER ARRAY grid # 2. INTEGER k # 3. STRING ARRAY rules AUDUSD 0.65063 A Autocomplete Ready O I main X Custom Input (5) Trading View Forex x Netflix Stocktwits-The lar..... M Medium-Get smar..... Given a grid with n rows and m columns of binary integers, 0 or 1, and a set of rules, simulate k turns of the game on this grid. The given grid denotes the initial configuration for the game, where grid[i] [] = 1 denotes that cell in the throw and th column is alive, and grid[i] = 0 denotes that this cell is dead. Two cells are neighbors when they share at least one common corner, thus each cell has at most 8 neighbors, as shown in the picture below: There is a list of 9 rules indexed from 0 to 8, each rule having a value of either 'alive' or 'dead'. A single rule, let's say rule i, specifies what happens to the cells with exactly i alive neighbors. In each turn, the new value of a cell is determined by counting the number of "alive' neighbors and applying the rule at index corresponding to the count. As an example, consider a rule set where rules at indices 3 and 5 are 'alive'. All of the other rules are dead. The following shows the process for two turns starting with the grid given in turn 0: Turn 0 Grid 0110 1100 White cell with 8 neighbors 1100 0110 0110 1100 Live neighbors for each cell 3321 2331 2331 3321 The "Live neighbors for each cell" grid at turn 7 contains the number of adjoining live cells at each grid position for turn 0. It is used to create the new grid state for turn 7. At each cell with a value of 3 or 5, the David Paul Th X top Washington Post: B... ⠀⠀⠀ Python 3 TTTT AWNINGSAWNHO 1 >#!/bin/python3... 10 1 11 # 14 15 16 17 18 19 # 20 (5) Alan Watts-Outw x NA 22 23 24 > if 21 def gridGame (grid, k, rules): #Write your code here name Test Results The New York Time... DeviantArt-Discov... 12 # Complete the 'gridGame function below. 13 # # The function is expected to return a 2D_INTEGER ARRAY. # The function accepts following parameters: # 1. 2D INTEGER ARRAY grid # 2. INTEGER k # 3. STRING ARRAY rules AUDUSD 0.65063 A Autocomplete Ready O I main X Custom Input (5) Trading View Forex x Netflix Stocktwits-The lar..... M Medium-Get smar.....
Expert Answer:
Answer rating: 100% (QA)
The gridGame function is written as follows The funct... View the full answer
Related Book For
Applied Statistics And Probability For Engineers
ISBN: 9781118539712
6th Edition
Authors: Douglas C. Montgomery, George C. Runger
Posted Date:
Students also viewed these programming questions
-
The stock of Jones Trucking is expected to return 13 percent annually with a standard deviation of 8 percent. The stock of Bush Steel Mills is expected to return 17 percent annually with a standard...
-
The stock of Koch Brickyard, Inc., is expected to return 14 percent with a standard deviation of 5 percent. Uptown Potbelly Stove Works stock is expected to return 16 percent with a standard...
-
If a project costs $100,000 and is expected to return $25,000 annually, how long does it take to recover the initial investment? What would be the discounted payback period at i = 15%?
-
The Chicago Omni Hotel is a 750-room luxury hotel offering guests the finest facilities in downtown Chicago. The hotel is organized into four departments: lodging, dining, catering, and retail...
-
Why has financial reporting fraud become more prevalent as the financial markets have expanded? What is the motivation for privately owned businesses to commit financial reporting fraud; aren't the...
-
You are called as an expert witness to analyze the following auto accident: Car B, of mass 1900 kg, was stopped at a red light when it was hit from behind by car A, of mass 1500 kg. The cars locked...
-
Healthy Bite Mart reported the following comparative income statement for the years ended November 30, 2010 and 2009. During 2010, Healthy Bite Mart discovered that the 2009 ending inventory, as...
-
Do you agree or disagree with the basic assumptions of Herzbergs dual-structure theory? Why?
-
Given $100,000 to invest, construct a value-weighted portfolio of the four stocks listed below. Stock Price/Share ($) Number of Shares Outstanding (millions) Golden Seas 14 1.42 Jacobs and Jacobs 22...
-
Demand and inventory on hand for five SKUs are presented in Table 2: Given that the demands are deterministic and in manhours, and the available manhours (Pt) for a cycle is 3000, i. determine the...
-
The quantity of charge q (in coulombs) that has passed through a surface of area 1.95 cm varies with time according to the equation q = 5t + 8t + 6, where t is in seconds. (a) What is the...
-
Imagine a situation where San Francisco's mayor initiates new regulation, allowing speedy conversion of vacant unrented offices throughout the Financial District to be used as rental residential...
-
If GDP per capita in 1970 was $4,997 and was growing at at annual rate of 4.5%, what is the estimated GDP per capita in 2014? GDP2014 per capita = $ (Round to two decimal places).
-
An empirical study by Kathrin (1996) showed that human capital investment is an inverse function of the degree of relative aversion. In this case, the higher the risk aversion, the less would be the...
-
Zach is the manager of a pharma company considered to be a monopoly that faces an inverse demand curve described by P = 270 - 20Q. If costs are defied as C = 30Q + 5. Zach's pharma firm's maximum...
-
The total expenditures (in millions) of current dollars for pollution abatement and control during the period from 2000 through 2019 can be approximated by the function P(x) 171.31007, where x 0...
-
A soil has loose and compacted volumes of 1.8LCM and 1CCM, respectively. Its swell is 20%. Select the answer from the alternatives below which is closest to the shrinkage of this soil measured as a...
-
Imagine that your best friend knows you are taking a psychology course and wonders what psychology is all about. How would you define psychology for your friend? Write an essay on the discipline of...
-
Construct a 95% lower confidence interval for the proportion of patients with kidney stones successfully removed in Exercise 9-95. Does this confidence interval support the claim that at least 78% of...
-
Construct a histogram for the water quality data in Exercise 6-24. Comment on the shape of the histogram. Does it convey the same information as the stem-and-leaf display?
-
In the book Bayesian Inference in Statistical Analysis (1973, John Wiley and Sons) by Box and Tiao, the total product yield for five samples was determined randomly selected from each of six randomly...
-
Using the fourth-order Runge-Kutta method, solve Problem 11.15. Data From Problem 11.15:- Using the second-order Runge-Kutta method, solve the differential equation \(\ddot{x}+1000 x=0\) with the...
-
Using the central difference method, find the response of the two-degree-of-freedom system shown in Fig. 11.2 when \(c=2, F_{1}(t)=0, F_{2}(t)=10\). Figure 11.2:- X1(t) -x2(t) F(1) k=2 -F2(t) k = 4...
-
Using the central difference method, find the response of the system shown in Fig. 11.2 when \(F_{1}(t)=10 \sin 5 t\) and \(F_{2}(t)=0\). Figure 11.2:- X1(t) -x2(t) F(1) k=2 -F2(t) k = 4 k2=6 00000...
Study smarter with the SolutionInn App