in reply to Simulating Drawing From A Bag
Nevertheless, regarding your code, I think there is a problem:
This will make the chance for a 0 double the chance of any other number.$x = $x > 0 ? $x - 1 : $x;
I wouldn't use splice. I'd go te way of really shuffling the array and then printing it either complete or using the elements in sequence one by one.
For shuffling seethe link I gave above.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simulating Drawing From A Bag
by YAFZ (Pilgrim) on Jun 12, 2003 at 10:52 UTC |