Pumkinhead_Me's blog

By Pumkinhead_Me, history, 6 months ago, In English

Let's say I have a big range (<= 1e9) from l to r. I need to generate N distinct numbers from this range using testlib. What would be the cleanest way to do that?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
6 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

assuming N satisfies at least(N<<<R-L+1) , then just use rnd.next(l, r) in a loop with a hash set

»
6 months ago, hide # |
 
Vote: I like it +51 Vote: I do not like it

it is already implemented:

auto values = rnd.distinct(N, l, r);