# need help.

This is a discussion on need help. within the C Programming forums, part of the General Programming Boards category; Code: /** Random walk problem statement: ------------------------------ Simulate the walk of a drunkard in a square street grid. Begin with ...

1. ## need help.

Code:
```/**
Random walk problem statement:
------------------------------
Simulate the walk of a drunkard in a square street grid.  Begin with
a simulated inebriated person in the middle of the grid.  Label this
beginning point the origin (0,0).  At each street intersection, the
drunkard randomly chooses the direction to walk, that is east, west,
north or south.  After 100 such random decisions, what distance,
measured in units of the grid or city blocks, has the drunkard
traveled?  Measure the distance using the distance formula for
the x-y plane.

Repeat the above simulation 10 times.  Report the average and the
median distance traveled in the 10 simulations.
*/

//prototype the function
double random_walk();

int main()
{

//call the random_walk() function 10 times

return 0;
}

//implement the function
//simulate the random walk, of 100 choices
double random_walk()
{

}```
not too sure where to start.

2. Making a matrix for the grid is a good start. Check out your random functions, as well.

You could have some lines on the screen to simulate the streets, and you'll need to use some ascii char's for the drunkard.

If you don't have an ascii chart yet, I'd google for it, and d/l one - very handy.

You'll also need the equation he specified to measure the distance the drunk travels, so google that, as well.

Dr. Math usually has good stuff like this around.

Really a fun assignment, imo.

3. No need for a matrix. Just keep track of the x and y position of the drunk after each move. Generate 1 of 4 random numbers each move and update x or y +/-1 each time.

Distance is just basic Pythagorean theorem stuff.

Figure out what the prof wants for the median of a set with an even number of values.