vendredi 20 avril 2018

Create random sequence of integers within a range and with a minimum distance between them

What is the fastest way to generate a specific nr of integers of random value within a specific range and with a minimum distance between each element?

For example, given a sequence range between 0 and 20, we want to create 5 elements with at least 3 points distance between each element, the result could be something like this [0,5,11,14,19] or [2,5,9,13,18]

I created a loop that achieves this but it is very slow when i want to create ranges in the order of millions.




Aucun commentaire:

Enregistrer un commentaire