Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e475f7fb4 | |||
| 540e80e009 | |||
| ac6946e442 |
@@ -0,0 +1,31 @@
|
|||||||
|
Valentin Loison
|
||||||
|
Dimitri Solar
|
||||||
|
Jannie Ngoy Ituka
|
||||||
|
Tarehi Zaabay
|
||||||
|
# Qualité Algo : TD2
|
||||||
|
| Fonction | Noeuds (N) | Arêtes (E) | Complexité M = E - N + 2P = … avec P = 1 | M = décisions + 1 = … | Classement du code : | Cas particulier ? |
|
||||||
|
| --- | --- | --- | --- | --- | --- | --- |
|
||||||
|
| C1 | | | | 1 | Simple | Non |
|
||||||
|
| C2 | 5 | 5 | 3 | 3 | Simple | Non |
|
||||||
|
| C3 | | | | 4 | Simple | && et |
|
||||||
|
| C4 | 10 | 16 | 8 | 8 | Simple | Non |
|
||||||
|
| C5 | | | | 9 | Simple | Non |
|
||||||
|
| C6 | | | | 11 | Modéré | Non |
|
||||||
|
| J1 | | | | 1 | Simple | Non |
|
||||||
|
| J2 | 6 | 8 | 4 | 4 | Simple | &&` |
|
||||||
|
| J3 | | | | 8 | Simple | Non |
|
||||||
|
| J4 | | | | 8 | Simple | Non |
|
||||||
|
| J5 | | | | 11 | Modéré | Non |
|
||||||
|
| J6 | 23 | 29 | 8 | 8 | Simple | Non |
|
||||||
|
| P1 | | | | 1 | Simple | Non |
|
||||||
|
| P2 | | | | 3 | Simple | Non |
|
||||||
|
| P3 | 6 | 8 | 4 | 4 | Simple | encadrement 0<=n<=20 on peut considérer ça comme 2 ifs, donc 2 décisions |
|
||||||
|
| P4 | | | | 2 | Simple | |
|
||||||
|
| P5 | | | | 15 | Modéré | |
|
||||||
|
|
||||||
|
# Images
|
||||||
|
|
||||||
|
Pour accéder aux images aller dans le dossier 'img' .
|
||||||
|
|
||||||
|
|
||||||
|
voir exercices.py pour le code refactorisé.
|
||||||
@@ -33,39 +33,66 @@ def mention(moyenne):
|
|||||||
return libelle
|
return libelle
|
||||||
return "Ajourné"
|
return "Ajourné"
|
||||||
|
|
||||||
|
def analyser_caractere(c,majuscule,minuscule,chiffre,special):
|
||||||
|
|
||||||
# Exercice P5
|
if c.isupper():
|
||||||
def analyser_mot_de_passe(mdp, login=None):
|
majuscule = True
|
||||||
problemes = []
|
elif c.islower():
|
||||||
if len(mdp) < 12:
|
minuscule = True
|
||||||
|
elif c.isdigit():
|
||||||
|
chiffre = True
|
||||||
|
else:
|
||||||
|
special = True
|
||||||
|
return majuscule,minuscule,chiffre,special
|
||||||
|
|
||||||
|
def verif_petit(len, problemes):
|
||||||
|
if len <12:
|
||||||
problemes.append("trop court")
|
problemes.append("trop court")
|
||||||
majuscule = minuscule = chiffre = special = False
|
|
||||||
for c in mdp:
|
def verif_no_min_maj(min,maj,problemes):
|
||||||
if c.isupper():
|
if not (maj and min):
|
||||||
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")
|
problemes.append("mélanger majuscules et minuscules")
|
||||||
|
|
||||||
|
def verif_chiffre(chiffre,problemes):
|
||||||
if not chiffre:
|
if not chiffre:
|
||||||
problemes.append("ajouter un chiffre")
|
problemes.append("ajouter un chiffre")
|
||||||
|
|
||||||
|
def verif_special(special,problemes):
|
||||||
if not special:
|
if not special:
|
||||||
problemes.append("ajouter un caractère spécial")
|
problemes.append("ajouter un caractère spécial")
|
||||||
|
|
||||||
|
def verif_mdp_is_not_login(login,mdp,problemes):
|
||||||
if login and login.lower() in mdp.lower():
|
if login and login.lower() in mdp.lower():
|
||||||
problemes.append("ne pas contenir le login")
|
problemes.append("ne pas contenir le login")
|
||||||
|
|
||||||
|
def verif_carac_identique(mdp,problemes):
|
||||||
for i in range(len(mdp) - 2):
|
for i in range(len(mdp) - 2):
|
||||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||||
problemes.append("éviter 3 caractères identiques")
|
problemes.append("éviter 3 caractères identiques")
|
||||||
break
|
return
|
||||||
|
def verif_fort(problemes):
|
||||||
if not problemes:
|
if not problemes:
|
||||||
return "fort", []
|
return "fort", []
|
||||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||||
|
|
||||||
|
|
||||||
|
def analyser_mot_de_passe(mdp, login=None):
|
||||||
|
problemes = []
|
||||||
|
majuscule = minuscule = chiffre = special = False
|
||||||
|
|
||||||
|
for c in mdp:
|
||||||
|
majuscule,minuscule,chiffre,special = analyser_caractere(c,majuscule,minuscule,chiffre,special)
|
||||||
|
print(majuscule,minuscule,chiffre,special)
|
||||||
|
|
||||||
|
verif_petit(len(mdp), problemes)
|
||||||
|
verif_no_min_maj(minuscule,majuscule,problemes)
|
||||||
|
verif_chiffre(chiffre,problemes)
|
||||||
|
verif_special(special,problemes)
|
||||||
|
verif_mdp_is_not_login(login,mdp,problemes)
|
||||||
|
verif_carac_identique(mdp,problemes)
|
||||||
|
|
||||||
|
return verif_fort(problemes)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print(celsius_vers_fahrenheit(20), signe(-3), notes_valides([12, 25, -1, 8]),
|
print(celsius_vers_fahrenheit(20), signe(-3), notes_valides([12, 25, -1, 8]),
|
||||||
mention(13.5), analyser_mot_de_passe("Motdepasse123!", "maxime"))
|
mention(13.5), analyser_mot_de_passe("Motdepasse123!", "maxime"))
|
||||||
|
|||||||
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 63 KiB |