cours_progra/27oct/ex4.py

16 lines
415 B
Python
Raw Normal View History

2022-10-27 16:33:09 +02:00
import random
def creer_enchevetrements(bag, i, max_en):
"""creer une suite d'enchevetrement aleatoire """
autre_baguettes = bag[:]
autre_baguettes.pop(i)
return [(random.choice(autre_baguettes), i) for _ in range(random.randint(1, max_en))]
if __name__ == "__main__":
for _ in range(100):
p = list(range(42))
random.shuffle(p)
print(creer_enchevetrements(p, 8, 10))