84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
有没有用Python生成n个不重复随机坐标的算法?比如范围(5,3)内的坐标:1 21 32 22 3等等
业精于勤,荒于嬉;行成于思,毁于随。
python 3
import itertools list(itertools.product(range(1, 6), range(1, 4)))
If randomization is needed, just randomly generate the index in the above list
import random n = 5 random_list = list(itertools.product(range(1, 6), range(1, 4))) random.sample(random_list, n)
import random n = 5 for x in random.sample(range(3 * 5), n): print('({}, {})'.format(*pmod(x, 3)))
python 3
If randomization is needed, just randomly generate the index in the above list