0
Non repeated random numbers
is there a way to randomize random number generation without repeating an already generated number?
2 odpowiedzi
+ 1
You can use a list to store the numbers that already present and create an if statement if the new random number is present in that list.
+ 1
You can track unique values with sets. A set does not allow duplicate values. You could then wrap this in a generator function so that it looks like all you ever return is unique values.
Note that you are breaking the very principle of randomness, a 'bad idea' in some contexts:
http://security.stackexchange.com/questions/2202/lessons-learned-and-misconceptions-regarding-encryption-and-cryptology/2210#2210