I'd like to create a million unordered list, xrange(1, 1000000)
for eg gives me an ordered list. I think I need something like xrange but generates it in an unordered fashion. I think I can generate a list manually by looping around random.randint
and some manual checks to guarantee uniqueness of number in list but I reckon it would be time consuming. Any ideas?
import random
L = range(1, 1000000)
random.shuffle(L) # shuffles in-place
on Python3, you will need to use
L = list(range(1, 1000000))
random.shuffle(L) # shuffles in-place