This is what I have so far but it breaks if I go past plus or minus 11 the previous number. So if the previous number is 1 the next number has to be more than 16. Also Im trying to only use each number once.
Example output:
[3,45, 1, 16, 33, 3, 23.....]
import random
new_array=[]
counter = 0
array=range(51)
array=array[1:51]
while len(new_array)<50:
y=random.choice(array)
if y not in new_array and counter!=0 and y not in (range(new_array[counter-1]-11,new_array[counter-1]+11)):
new_array.append(y)
counter+=1
elif counter == 0:
new_array.append(y)
counter+=1
else:
pass
Aucun commentaire:
Enregistrer un commentaire