That is not a fair algorithm. @avail shrinks during your loop, so the range rand(@avail) picks from does as well, and thus chances for any one number to be picked increase with each iteration.
Makeshifts last the longest.
In reply to Re^2: How to generate distinct random numbers?
by Aristotle
in thread How to generate distinct random numbers?
by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |