diff --git a/COMPTE_RENDU.md b/COMPTE_RENDU.md new file mode 100644 index 0000000..0cc20d7 --- /dev/null +++ b/COMPTE_RENDU.md @@ -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 . + + +voir exercices.py pour le code refactorisé. \ No newline at end of file diff --git a/exercices.py b/exercices.py index 691fb9b..237395a 100644 --- a/exercices.py +++ b/exercices.py @@ -33,39 +33,66 @@ def mention(moyenne): return libelle return "Ajourné" +def analyser_caractere(c,majuscule,minuscule,chiffre,special): -# Exercice P5 -def analyser_mot_de_passe(mdp, login=None): - problemes = [] - if len(mdp) < 12: + if c.isupper(): + majuscule = True + elif c.islower(): + 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") - 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): + +def verif_no_min_maj(min,maj,problemes): + if not (maj and min): problemes.append("mélanger majuscules et minuscules") + +def verif_chiffre(chiffre,problemes): if not chiffre: problemes.append("ajouter un chiffre") + +def verif_special(special,problemes): if not special: 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(): problemes.append("ne pas contenir le login") + +def verif_carac_identique(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 + return +def verif_fort(problemes): if not problemes: return "fort", [] 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__": print(celsius_vers_fahrenheit(20), signe(-3), notes_valides([12, 25, -1, 8]), mention(13.5), analyser_mot_de_passe("Motdepasse123!", "maxime")) diff --git a/img/c2.png b/img/c2.png new file mode 100644 index 0000000..79687aa Binary files /dev/null and b/img/c2.png differ diff --git a/img/c4.png b/img/c4.png new file mode 100644 index 0000000..6da2a5a Binary files /dev/null and b/img/c4.png differ diff --git a/img/j2.png b/img/j2.png new file mode 100644 index 0000000..111edd0 Binary files /dev/null and b/img/j2.png differ diff --git a/img/j4.png b/img/j4.png new file mode 100644 index 0000000..a31ea6d Binary files /dev/null and b/img/j4.png differ diff --git a/img/j6.png b/img/j6.png new file mode 100644 index 0000000..a31ea6d Binary files /dev/null and b/img/j6.png differ diff --git a/img/p2.png b/img/p2.png new file mode 100644 index 0000000..5a7acc7 Binary files /dev/null and b/img/p2.png differ diff --git a/img/p3.png b/img/p3.png new file mode 100644 index 0000000..fbbf986 Binary files /dev/null and b/img/p3.png differ