I am trying to generate N random numbers with X number of digits such that the difference is always positive.
The best way I could think to do this was to generate N numbers
10,11,30,49,50 then sort them, 50,49,30,11,10 and find the difference -50 and if it's negative, like in this case, I would do the whole process over again.
As you can imagine, this is a very brute force way and is slow. Is there a better way to do this?
N and X are a maximum of 5 if that helps.
Aucun commentaire:
Enregistrer un commentaire