jeu_des_allumettes_complete.py

Created by elodie-gamot

Created on July 07, 2022

747 Bytes


from math import *
from random import *

allumettes=[i for i in range(20)]
print("l"*len(allumettes))

while len(allumettes)>1:
  sub=int(input("Choisir un nb entre 1 et 3:"))
  for i in range(sub):
    allumettes.remove(allumettes[-1])
  print("l"*len(allumettes))
  if len(allumettes)==1:
    print("Vous avez gagné")
  else:
    if len(allumettes)%4==3:
      ia=2
    elif len(allumettes)%4==2:
      ia=1
    elif len(allumettes)%4==0:
      ia=3
    else:
      ia=randint(1,3 if len(allumettes)>3 else len(allumettes)-1)
    print("L'IA enlève",ia)
    for i in range(ia):
      allumettes.remove(allumettes[-1])
    print("l"*len(allumettes))
    if len(allumettes)==1:
      print("Vous avez perdu !")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.