I would like to generate random numbers in the range (0..."MAX"). I would like to make a loop such that every time going through the loop a new unique random number is generated (should not repeat). The loop will continue a total of "MAX" times. There should be "MAX" number of random numbers generated in total. When sorted, the values should be 0..."MAX"; no repetition.
Restrictions: - Assume MAX is much larger than int. (no memory to store all number permutations in memory)
My proposed solution: If I seed the generator from 0...MAX would that allow me to print every unique number between 0 and MAX as in the below function? Assume there's no space to store all numbers and shuffling them.
for x in range (0, MAX):
random.seed(x)
num=random.randint(0, MAX)
print("seed = ",x, " random number = ", num)
If the answer for the above is yes then would this generation be reversible (can i get the seed from the random number)? In which case would this be considered a kind of block cipher that is if the seed (key) and the range is the same length?
randintrequires arguments. Also, nothing in your code will prevent repetitions. Why are you seeding the generator anew on each iteration?MAX?