dot=[]
def generate():
global dot
dot.append([random.randrange(0, dots), random.randrange(0, dots)])
while len(dot)<dots-1:
randX = random.randrange(0, dots)
randY = random.randrange(0, dots)
for i in range(len(dot)):
if dot[i][0]!=randX and dot[i][1]!=randY:
dot.append([random.randrange(0, dots), random.randrange(0, dots)])
def generate(dots):
dot = list(range(dots))
for i in range(dots):
x = random.randrange(0, dots)
dot[i] , dot[x] = dot[x], dot[i]
return dot
dot = generate(dots)
In [3]: from random import randint
In [4]: def t(list_len=10):
list_ = []
while len(list_) < list_len:
r = randint(0, list_len * 10)
if r not in list_: list_.append(r)
return list_
...:
In [5]: t()
Out[5]: [34, 21, 49, 40, 81, 78, 95, 63, 31, 29]
In [6]: t(20)
from random import randint
def generate(dots):
a = set()
while len(a) < dots:
a.add((randint(0, dots), randint(1, dots)))
return list(a)
return [list(i) for i in list(a)]