jeudi 6 décembre 2018

How to create a repeating n number of coordinates within the range (0,2) where n is much greater than all possible combinations

I want to generate a random set of coordinates where x and y are within the range (0,2). Repeating one combination is allowed. I tried the following code.

possible_coordinates = [(x, y) for x in range(3) for y in range(0,2)]
bomb_coordinates = random.sample(possible_coordinates, k=70)

It gives the expected result until the K=6 where k is the required number of coordinate pairs. But when k exceeds 6, it gives an error in random.py.

Please help me out to generate 50 pairs of random coordinates.




Aucun commentaire:

Enregistrer un commentaire