Hi I'm doing this for a school project (so I can't use any advanced features) and I'm using Python 2.6.6.
I have a list of numbers from 1 to 1000 and my seed will be, lets say, 448.
How can i generate a random sequence with that seed so that the numbers in my list will be in a different index?
And is it possible, knowing the seed, return the elements in my list to the initial position?
Sorry if it's confuse but English is not my native language.
Thanks,
Favolas
results in
Your list is now pseudorandomized.
'Pseudo' is important, because all lists having the same seed and number of items will return in the same 'random' order. We can use this to un-shuffle your list; if it were truly random, this would be impossible.
results in
Tada! originalList is now the original ordering of myList.
A simple check on the python docs http://docs.python.org/library/random.html tells you about
which you can use to initialize the seed.
To get the items in the order of your initial again, set the seed again and get the random numbers again. You can then use this index to get the content in the list or just use the index for whatever.
You’d just sort the list and it’d be in sorted order again.