|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: Difficulty in randomizationby kejohm (Hermit) |
| on Mar 04, 2012 at 21:41 UTC ( #957816=note: print w/ replies, xml ) | Need Help?? |
|
Instead of using if in your loop, you can use a do {...} while loop, eg:
Here we generate a random number inside the loop and check whether the element at that position has been assigned 'X'. If it is, we try again. Otherwise, we assign 'X' to the selected element.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||