Created
February 13, 2011 14:22
-
-
Save hlidotbe/824716 to your computer and use it in GitHub Desktop.
fort_boyard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Initialisation allumettes et tour | |
n = 15 | |
tour = 0 | |
# Tant qu'il reste des allumettes | |
while n > 0: | |
# On initialise a -1 | |
allu = -1 | |
# Tant que le joueur ne retire pas un nombre valide on lui redemande le | |
# nombre a retirer | |
while allu > 3 or allu < 1 or n - allu < 0: | |
print "joueur", tour%2+1,"a vous de jouer" | |
print "il reste", n, "allumette(s), combien d'allumettes allez vous retirer?" | |
allu = int(raw_input()) | |
# On retire les allumettes du total | |
n = n-allu | |
# On incrémente le tour | |
tour = tour + 1 | |
# Si il ne reste plus d'allumettes, le joueur suivant a gagné | |
print "Le joueur",(tour%2)+1,"a gagne!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment