On Aug 18, 2010, at 3:23 PM, brabuhr / gmail.com wrote: > On Wed, Aug 18, 2010 at 2:42 PM, Jean-Julien Fleck > <jeanjulien.fleck / gmail.com> wrote: >>> how can i set the passenger for each vehicle? like for example >>> i input vehicles number: 5 >>> how can set the passenger of vehicle 1 which is it only allow 1 >>> passenger >> >> I think you misread the problem: nobody says that the first vehicle >> have to have 1 passenger. All it says is that if you take a pool of >> 100 vehicles, 20 of them will have only 1 passenger, 30 2 passengers, >> 10 3 passengers, 10 4 passengers and the 30 remaining will be buses >> of >> 40 passengers. > > Bruce, > > Consider a simpler case w/ pencil, paper, and a coin. Assume that 50% > of vehicles have 2 passengers and 50% have 3. How would you do it? > Maybe something like: > > Flip coin > If result is heads then > vehicle will have 2 passengers > Otherwise, if result is tails > vehicle will have 3 passengers > Otherwise > wow, edge!? > > Let's make that more code-like: > > result = rand(2) > if result == 0 > puts "2" > else > puts "3" > end > OK, I know this thread is going for some kind of record, but like any good wreck it's so hard not to look. Why isn't anyone saying "make an object"? Well, I will! http://gist.github.com/536140 (Yeah, I know Bruce ought to do this himself, but I'm tired and this allowed me to procrastinate a bit.) -Rob Rob Biedenharn Rob / AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab / GaslightSoftware.com http://GaslightSoftware.com/