Write a method called randomWalk that performs steps of a random one-dimensional walk. The random walk should begin at position 0. On each step, you should either increase or decrease the position by 1 (each with equal probability). Your code should continue making steps until a position of 3 or −3 is reached, and then report the maximum position that was reached during the walk. The output should look like the following:
position = 1position = 0position = −1position = −2position = −1position = −2position = −3max position = 1
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.