From: Josh Cheek Date: 2010-08-18T04:17:40+09:00 Subject: Re: can i do this in ruby? a simulation process --001485f46efae7644d048e09ccec Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Aug 17, 2010 at 4:39 AM, Jean-Julien Fleck < jeanjulien.fleck@gmail.com> wrote: > > Requirements: > > 1. A simulation process of the movement of vehicles from one point to > > another. > > 2. The time (in minutes) for 500 people to arrive in the second city. > > > > i can't even think on how can i start this one in ruby a newbie like me > > have only limited knowledge on ruby. can someone help with my program? > > You sure can do it in ruby but first you have to decide what ruby have > to do for you: take a sheet of paper and write down the differents > steps each Vehicle has to go throught in order to reach the second > city. I'm sure you will see more clearly what you have to do next to > implement each step. > > Hint: it have to do with probability distributions and you will most > certainly need the metho 'rand' > > Cheers, > > -- > JJ Fleck > PCSI1 Lyc=E9e Kl=E9ber > > I'm not sure how much your simulation needs to include, on one hand, you have the pure mathematical analysis, on the other, probably count each second. You could probably argue that it is purer in so far as it adheres t= o the concept of "simulating". Plus it is easy: For each second, check to see if a vehicle should be departing, if so, add it to an array of vehicles in transit. And check the array of vehicles in transit to see if a vehicle is arriving, if so, remove it from the in transit array, and add its passenger= s to a sum. Then just increment seconds and iterate until >=3D 500 passengers have arrived. I was getting about 783 seconds when the first vehicle leaves at zero seconds, and 804 seconds when the first vehicle leaves 5-35 seconds after time starts. --001485f46efae7644d048e09ccec--