cours_progra/bac1/q1/27oct/ex7.py
Debucquoy 4fd7542f03
.
2023-09-20 15:18:20 +02:00

34 lines
754 B
Python

from ex6 import peut_retirer, retirer
def quel_ordre(_bag, jeu):
"""retourne un ordre possible sinon None """
bag = _bag[:]
order = list()
last_order = None
while order != last_order:
last_order = order[:]
print(last_order)
for i in bag:
if peut_retirer(i, bag, jeu):
order.append(i)
retirer(i, bag, jeu)
bag_t, order_t = bag[:], order[:]
bag_t.sort()
order_t.sort()
print(order_t, bag_t)
if(order_t == bag_t):
return order
else:
return None
if __name__ == "__main__":
from ex5 import creer_mikado
bag = list(range(10))
game = creer_mikado(bag)
print(bag)
print(game)
print(quel_ordre(bag, game))