Let's say I want to generate a random integer list, so I use this program, and set my seed to 10:
import random
random.seed(10)
randomlist = random.sample(range(0, 5), 5)
print(randomlist)
The output will be always [4, 0, 1, 2, 3], because I set my seed to 10. That's why I get the same result over and over.
But my question is: it possible to get the seed number from an unknown random value?
For instance, I have a random list:
mylist = [3, 2, 0, 1, 2] # 5 item with range of 0 to 5
I wrote this random list my own, (I didn't use any kind of program), but I can generate the same random list with the random
module and the help of loop - just pass the loop iteration in random.seed()
function on my previous program.
But I want to get the seed value from the "mylist" variable without a loop, like so:
def GetSeed(mylist,start_range,stop_range):
return "And The Program returned the seed number"
Is this possible?
Aucun commentaire:
Enregistrer un commentaire