As title says 100 random unique values from two ranges or to be more accurate there is one range and a subrange that is excluded from valid values.
Example have a range from 0 to 10000, random 100 numbers that are not in range 10 to 20
Requirements:
- The Subrange can be at the very beginning or at the very end.
- Memory overhead to absolute minimum.
- Randomization as close to random.shuffle() as possible.
I know random.sample(xrange(0,10000),100) gives 100 unique values.
Setup I would store three values [start,end,total]
- start = start of subrange
- end = end of subrange
- total = the length of the range
Best I can come up with:
randlist=[]
while len(randlist)<100:
temp=random.randint(0,total)
if temp < start or temp > end:
if temp not in randlist:
randlist.append(temp)
Is this true random(pseudorandom) or am I affecting it in any way?