vendredi 21 avril 2017

Random Sampling without Replacement in Ruby

Is there some function in ruby that generates k random numbers in a range without replacement (repetition)?

Something like the random.sample function in Python as shown below

>>> import random
>>> random.sample(range(1, 100), 3)
[77, 52, 45]




Aucun commentaire:

Enregistrer un commentaire