cours_progra/q1/27oct/ex4.py
2023-02-15 13:40:50 +01:00

16 lines
415 B
Python

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))