dimanche 19 août 2018

Python: Random list of numbers in a range keeping with a minimum distance

Let's say this code random.seed(42) random.sample(range(0,40), 4) Output:[7, 1, 17, 15] What should I change in this code to generate random numbers where the minimum distance between any two numbers in the list will be be at least 10 or more. Something like [0, 10, 25, 39] or [0, 12, 23, 38 ]. Possible duplicate would be this. Thanks.




Aucun commentaire:

Enregistrer un commentaire