DEV Community

Discussion on: An algorithm for picking random numbers in a range without repetition

babak profile image
Babak Author

Hey! One could just wrap the existing function to create the effect. max_length is the difference between high and low. Then add the low value to the output.

jonathanschuma profile image

I was rather looking for a function that would return x random unique samples from an arbitrary range than a shuffle function and stumbled on your post.
I really like the method but sadly couldnt get it quite to work.
I was hoping to find something that would use pure arithmetical operations to pick a unique sample from rand range.
There has to be a way.