From: Andrew Wagner Date: 2010-08-17T20:34:53+09:00 Subject: Re: can i do this in ruby? a simulation process --0016e6d975ba17e093048e03561e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hmm, I may or may not disagree with you on what the output should be. I can't speak for his assignment, but in real life, I would think it would be more useful to perform the simulation some number of times, printing out th= e number of seconds it took to get to 500 passengers each time, and the average of all the trials. It's not clear to me from the description of the assignment whether the requirement is for the results of a single trial (rather silly) or an average. Anyway, I did this, for fun, and consistently got an average of around 833 seconds on average for 100000 trials. Anyone else give this a shot? I'm curious to see whether different implementations give different results. Th= e standard deviation seems to be pretty high. On Tue, Aug 17, 2010 at 6:00 AM, Jean-Julien Fleck < jeanjulien.fleck@gmail.com> wrote: > > Cheers Thanks, anyway i already did writing and other stuff but the onl= y > > problem is that i don't know to start my code. :( > > Try to create a Vehicle class where you compute the arrival time and > the number of passengers based on a departure time. Then make a loop > of say 500 vehicles (to be sure everybody arrive at the end) and > create a list of vehicles that are launched every 5-35s. Do not forget > to sort the list based on arrival time rather than departure time. > > In the end, it should give you something like > > [...] > 442 passengers where there after 654 seconds > 444 passengers where there after 691 seconds > 448 passengers where there after 717 seconds > 449 passengers where there after 746 seconds > 489 passengers where there after 761 seconds > 529 passengers where there after 790 seconds > > Cheers, > > -- > JJ Fleck > PCSI1 Lyc=C3=A9e Kl=C3=A9ber > > --0016e6d975ba17e093048e03561e--