Vous êtes sur la page 1sur 2

# Procédure Remplissage_Fichier # Procédure Remplissage_Fichier MOTS

MOTS def fremplir1():


def fremplir1(): f = open ("MOTS.txt", "w")
f = open ("MOTSv12.txt", "w") nom= ""
nom = input("Saisir NOM : ") while (nom.upper() != "FIN") :
while (nom.upper() != "FIN" ) : nom = input("Saisir NOM : ")
while (alpha1 (nom)==False): while (alpha1 (nom)==False):
nom = input("--NOM : ") nom = input("Saisir NOM : ")
mot1 = input("Saisir mot1 : ") mot1 = input("Saisir mot1 : ")
while (alpha2 (mot1)==False): while (alpha2 (mot1)==False):
mot1 = input("---Saisir mot1 : mot1 = input("Saisir mot1 : ")
") mot2 = input("Saisir mot2 : ")
mot2 = input("Saisir mot2 : ") while (alpha2(mot2)==False):
while (alpha2(mot2)==False): mot2 = input("Saisir mot2 : ")
mot2 = input("--- mot2 : ") mot3 = input("Saisir mot3 : ")
mot3 = input("Saisir mot3 : ") while (alpha2 (mot3)==False):
while (alpha2 (mot3)==False): mot3 = input("Saisir mot3 : ")
mot3 = input("--- mot3 :")

ch=nom+"-"+mot1+"-"+mot2+"-"+m ch=nom+"-"+mot1+"-"+mot2+"-"+mot3
ot3 f.write (ch+"\n")
f.write (ch+"\n") nom = input("Saisir NOM : ")
nom = input("Saisir NOM : ") f.close( )
f.close( )

# fonction score def score(ch,t) :


def score(ch,t) : score=0
i=0 ch+="-"
test=True while(ch.find("-") !=-1):
debut=0 mot=ch[0:ch.find("-")]
score=0 ch=ch[ch.find("-")+1:]
# 2 methode ch+="-" i=0
while(i<len(ch)) : debut=0
test=False test=True
j=debut while(i<len(mot) ) and (test
while (j<40) and (test==False): ==True):
if (ch[i]==t[j]): test=False
test=True j=debut
debut=j+1 while (j<40) and (test==False):
elif (ch[i]=="-"): if (mot[i]==t[j]):
test=True test=True
debut=0 debut=j+1
score=score+1 else :
j=j+1
else : i+=1
j=j+1 if (test==True) :
if(test==False)and (i<len(ch)-1): score=score+1
ch2=ch[i:]
p=ch2.find("-")
# 2 methode i+=ch2.find("-") return score
if p>-1:
i=i+p
else:
i=len(ch)
debut=0
i=i+1
if (test == True):
score+=1
return score
# Procédure Remplissage_Fichier MOTS # Procédure Remplissage_Fichier MOTS
def fremplir1(): def fremplir1():
f = open ("MOTSv12.txt", "w") f = open ("MOTS.txt", "w")
nom = input("Saisir NOM : ") nom= ""
while (nom.upper() != "FIN" ) : while (nom.upper() != "FIN") :
while (alpha1 (nom)==False): nom = input("Saisir NOM : ")
nom = input("--NOM : ") while (alpha1 (nom)==False):
mot1 = input("Saisir mot1 : ") nom = input("Saisir NOM : ")
while (alpha2 (mot1)==False): mot1 = input("Saisir mot1 : ")
mot1 = input("---Saisir mot1 : ") while (alpha2 (mot1)==False):
mot2 = input("Saisir mot2 : ") mot1 = input("Saisir mot1 : ")
while (alpha2(mot2)==False): mot2 = input("Saisir mot2 : ")
mot2 = input("--- mot2 : ") while (alpha2(mot2)==False):
mot3 = input("Saisir mot3 : ") mot2 = input("Saisir mot2 : ")
while (alpha2 (mot3)==False): mot3 = input("Saisir mot3 : ")
mot3 = input("--- mot3 :") while (alpha2 (mot3)==False):
mot3 = input("Saisir mot3 : ")
ch=nom+"-"+mot1+"-"+mot2+"-"+mot3
f.write (ch+"\n")
nom = input("Saisir NOM : ") ch=nom+"-"+mot1+"-"+mot2+"-"+mot3
f.close( ) f.write (ch+"\n")
nom = input("Saisir NOM : ")
f.close( )

# fonction score def score(ch,t) :


def score(ch,t) : score=0
i=0 ch+="-"
test=True while(ch.find("-") !=-1):
debut=0 mot=ch[0:ch.find("-")]
score=0 ch=ch[ch.find("-")+1:]
while(i<len(ch)) : i=0
test=False debut=0
j=debut test=True
while (j<40) and (test==False): while(i<len(mot) ) and (test
if (ch[i]==t[j]): ==True):
test=True test=False
debut=j+1 j=debut
elif (ch[i]=="-"): while (j<40) and (test==False):
test=True if (mot[i]==t[j]):
debut=0 test=True
score=score+1 debut=j+1
else : else :
j=j+1 j=j+1
if(test==False)and (i<len(ch)-1): i+=1
ch2=ch[i:] if (test==True) :
p=ch2.find("-") score=score+1
if p>-1:
i=i+p
else: return score
i=len(ch)
debut=0
i=i+1
if (test == True):
score+=1
return score

Vous aimerez peut-être aussi