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...
-
The null and alternate hypotheses are: H0: 1 = 2 H1: 1 2 (a) State the decision rule, (b) Compute the pooled estimate of the population variance, (c) Compute the test statistic, (d) State your...
-
Consider a system in which computer games can be played by students only between 10 P.M. and 6 A.M., by faculty members between 5 P.M. and 8 A.M., and by the computer center staff at all times,...
-
How do you prevent name clashes when using header files?
-
Ratio Computations and Additional Analysis Brad burn Corporation was formed 5 years ago through a public subscription of common stock. Daniel Brown, who owns 15% of the common stock, was one of the...
-
6. (a) Given == 2-23i.Find |=| and arg (=*). Hence, solve z=2-23i leave your answers in polar form. (b) Given that z = 1 + i is a root of the polynomial equation z4-4z3 +11z2 - 14z + 10 = 0. Find the...
-
1. What is the cost of debt for Sunrise Bakery? 2. What is their cost of equity? 3. What is the WACC? 4. Which cost of capital should be used to evaluate the feasibility of the oven purchase? 5....
-
What is the name of this product? HC- HC- O H
-
Given: Mg(s) + 2HCl(aq) MgCl(aq) + H(g). What type of reaction is shown above?
-
What is the output of the following code segment if the input is: A B C (recall that represents the return or enter key stroke), if there is one blank space between every pair of letters. char ch1,...
-
Assume that 0.491 g of diborane is combusted in a calorimeter whose heat capacity (Ccalorimeter) is 7.854 kJ/C at 25.92C. What is the final temperature of the calorimeter? C
-
83.0 mL of water was added to 100.0 mL of 0.250 M CaCl solution. Assume the volumes are additive. Determine the CaCl concentration in the diluted solution.
-
What is the fastest speed a tennis ball can cross the net horizontally and still land in 60= Vx the court? From the net to the end line is 12 m, and the height of the net is 1 m. Neglect air...
-
Bobby is subject to a 20% tax rate on dividends. Domer Inc's reports $ 5 million before taxes. The corporate tax rate is 20%. After taxes, Domer Inc. distributes all earnings as dividends. Domer has...
-
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...
-
Compare and contrast the terms public interest and public benefit in the context of public financial management.
-
Discuss M1, M2 and M3 monetary aggregates.
-
Compare and contrast direct and indirect taxes.
Study smarter with the SolutionInn App