subject

A two dimensional random walk simulates the behavior of a particle moving in agrid of points. At each step, the random walker moves north, south, east, or westwith probability14, independent of previous moves. Compose a program thattakes a command-line argumentnand estimates how long it will take a randomwalker to hit the boundary of a 2n-by-2nsquare centered at the starting point. How do I solve this?

So far i have the following:

import sys
import stdio
import random

# the size of the box, which should be 4
n = int(sys. argv[1])

# should be the amount of steps taken to reach the boundary/ end of the box.
c = int(sys. argv[2])

def random_walk_2D (n):
x, y = 0, 0
i = 4
North = 1; South = 2; West = 3; East = 4

for i in range(n):

people = random. randint(1,4)

while I < c:
stdio. write()

if people == 1:
y = y + 1
elif people == 2:
y = y - 1
elif people == 3:
x = x + 1
else :
x = x - 1
return (x, y)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:10
In mathematics and computer science, a set is a collection in which order does not matter and there are no duplicates. in this problem, we are going to to define a class which wil allow us to create an object to represent a set of integers. you will write a program set.java to define the class set. each instance of the class set will be an object representing a set of integers.
Answers: 3
question
Computers and Technology, 23.06.2019 03:10
Fill in the following program so that it will correctly calculate the price of the orange juice the user is buying based on the buy one get one sale.#include //main functionint main() { int cartons; float price, total; //prompt user for input information printf("what is the cost of one container of oj in dollars? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & price); printf("how many containers are you buying? \n"); scanf(" [ select ] ["%d", "%c", "%f", "%lf"] ", & cartons); if ( [ select ] ["cartons / 2", "cartons % 1", "cartons % 2", "cartons % price", "cartons / price", "cartons / total"] [ select ] ["=", "==", "! =", "< =", "> =", "< "] 0) total = [ select ] ["price * cartons", "cartons * price / 2 + price", "(cartons / 2) * price", "cartons / (2.0 * price)", "(cartons / 2.0) * price + price", "((cartons / 2) * price) + price"] ; else total = ((cartons / 2) * price) + price; printf("the total cost is $%.2f.\n", total); return 0; }
Answers: 2
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 24.06.2019 12:50
Write a new lc-3 trap subroutine (i.e. a subroutine that will be invoked via the trap instruction) that will receive a numeric digit entered at the keyboard (i.e. an ascii character), echo it to the screen, and return in r0 the corresponding numeric value: so if the user types the digit '7', the character '7' will appear on the screen, but the value returned in r0 will be b0000 0000 0000 0111 (#7) you may not use any trap calls in your code - you must implement the "polling" code that interrogates the keyboard status and data registers. ; getnum_tsr ; a subroutine for obtaining a numeric value ; given ascii numeric digit input to keyboard. ; the numeric digit is echoed to the console (e.g. '7' = b0000 0000 0011 0111), ; but the value returned in r0 is the actual numeric value ; corresponding to the digit (e.g. b0000 0000 0000 0111 =
Answers: 3
You know the right answer?
A two dimensional random walk simulates the behavior of a particle moving in agrid of points. At eac...
Questions
question
Mathematics, 28.07.2019 17:00
Questions on the website: 13722367