forked from menault/2026_TD2_DEV51_Qualite_Algo
4.7 KiB
4.7 KiB
Groupe :
- FRAMERY Karl
- ABRAHAM Ozvann
1. Dessiner le graphe
C2
C4
P2
P3
J2
J6
2. Compter les décisions
J1-J6
- J1 = 1
- J2 = 2 + 1 = 3
- J3 = 7 + 1 = 8
- J4 = 8 + 1 = 9
- J5 = 10 + 1 = 11
- J6 = 8 + 1 = 9
C1-C6
- C1 = 1
- C2 = 2 + 1 = 3
- C3 = 2 + 1 = 3
- C4 = 7 + 1 = 8
- C5 = 7 + 1 = 8
- C6 = 10 + 1 = 11
P1-P5
- P1 = 1
- P2 = 2 + 1 = 3
- P3 = 2 + 1 = 3
- P4 = 2 + 1 = 3
- P5 = 13 + 1 = 14
Complexité max : P5 = 14
3. Classer
-
C1 -> simple
-
C2 -> simple
-
C3 -> simple
-
C4 -> moyen
-
C5 -> moyen
-
C6 -> complexe
-
J1 -> simple
-
J2 -> simple
-
J3 -> complexe
-
J4 -> complexe
-
J5 -> complexe
-
J6 -> complexe
-
P1 -> simple
-
P2 -> simple
-
P3 -> moyen
-
P4 -> moyen
-
P5 -> complexe
4. Justifier les cas particuliers
C3
return (annee % 4 == 0 && annee % 100 != 0) || annee % 400 == 0;
L'utilisation des <&&> et <||> sont nécessaire pour une compréhention plus simple du code, sans leurs utilisation le code aurait nécéssité des if / else randant le code plus long et moins compréhensible / lisible.
5. Refactoriser
P5
def analyser_mot_de_passe(mdp, login=None):
problemes = []
if len(mdp) < 12:
problemes.append("trop court")
majuscule = minuscule = chiffre = special = False
for c in mdp:
if c.isupper():
majuscule = True
elif c.islower():
minuscule = True
elif c.isdigit():
chiffre = True
else:
special = True
if not (majuscule and minuscule):
problemes.append("mélanger majuscules et minuscules")
if not chiffre:
problemes.append("ajouter un chiffre")
if not special:
problemes.append("ajouter un caractère spécial")
if login and login.lower() in mdp.lower():
problemes.append("ne pas contenir le login")
for i in range(len(mdp) - 2):
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
problemes.append("éviter 3 caractères identiques")
break
if not problemes:
return "fort", []
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
Devien une fois transformé :
def analyser_mot_de_passe(mdp, login=None):
problemes = []
taille_mdp(mdp, problemes)
majuscule = caractere_majuscule
minuscule = caractere_minuscule
chiffre = caractere_chiffre
special = caractere_special
problemes(majuscule, minuscule, chiffre, special, login, mdp, problemes)
for i in range(len(mdp) - 2):
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
problemes.append("éviter 3 caractères identiques")
break
if not problemes:
return "fort", []
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
def problemes(majuscule, minuscule, chiffre, special, login=none, mdp, problemes[]):
if not (majuscule and minuscule):
problemes.append("mélanger majuscules et minuscules")
if not chiffre:
problemes.append("ajouter un chiffre")
if not special:
problemes.append("ajouter un caractère spécial")
if login and login.lower() in mdp.lower():
problemes.append("ne pas contenir le login")
def taille_mdp(mdp, problemes[]):
if len(mdp) < 12:
return problemes.append("trop court")
def caractere_majuscule(mdp):
majuscule = False
for c in mdp:
if c.isupper():
majuscule = True
return majuscule
def caractere_minuscule(mdp):
minuscule = False
for c in mdp:
if c.isupper():
minuscule = True
return minuscule
def caractere_chiffre(mdp):
chiffre = False
for c in mdp:
if c.isupper():
chiffre = True
return chiffre
def caractere_special(mdp):
special = False
for c in mdp:
if c.isupper():
special = True
return special





