Question: write this python program 5. Random walk. You may know that the streets and avenues of Manhattan form a grid. A random walk through the

 write this python program 5. Random walk. You may know that

write this python program

5. Random walk. You may know that the streets and avenues of Manhattan form a grid. A random walk through the grid (i.e., Manhattan) is a walk in which a random direction (N, E, S, or W) is chosen with equal probability at every intersection. For example, a random walk on a 5 11 grid starting at (5, 2) could visit grid points (6, 2), (7, 2), (8, 2), (9, 2), (10, 2), back to (9, 2) and then back to (10, 2) before leaving the grid. Write function manhattan ) that takes the number of rows and columns in the grid, simulates a random walk starting in the center of the grid, and computes the number of times each intersection has been visited by the random walk. Your function should print the table line by line once the random walk moves outside the grid. As an example, the call manhattan(5, 11) could produce the following output: Co, 0, o, o, 0, 0, 0, o, 0, 0, 0] [o, 0, 0, 0, 0, 0, 0, 0, o, 0, 0] to, 0, 0, 0, 0, 0, 0, 0, 0, o, 0] to, 0, 0, o, o, o, 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!