good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Perl - Unique Numbers (algorithm)by tye (Sage) |
on Oct 19, 2015 at 14:37 UTC ( [id://1145335]=note: print w/replies, xml ) | Need Help?? |
Heh, the algorithmically optimal (IMHO) way to get N unique numbers from a set of M of them is not actually covered in any of the replies. Not that this means you shouldn't use any of those solutions. I just think the method should be mentioned. The process is the same as that used in List::Util's shuffle(), the Fisher-Yates Shuffle, except you stop early.
- tye
In Section
Seekers of Perl Wisdom
|
|