cours_progra/27oct/ex5.py
2022-10-27 16:33:09 +02:00

19 lines
520 B
Python

import random
from ex4 import creer_enchevetrements
def creer_mikado(bag):
"""creer un sac de mikado avec des enchevetrement aleatoire """
game = list()
nombre_enchevetrements = random.randint(1, len(bag))
while len(game) < nombre_enchevetrements:
game.append(creer_enchevetrements(bag, random.choice(bag), 1)[0])
return game
if __name__ == "__main__":
for _ in range(100):
bag = list(range(random.randint(2, 42)))
random.shuffle(bag)
print(creer_mikado(bag))