Files

214 lines
4.7 KiB
Markdown
Raw Permalink Normal View History

2026-10-14 11:47:19 +02:00
Groupe :
- FRAMERY Karl
- ABRAHAM Ozvann
2026-10-14 12:00:22 +02:00
## 1. Dessiner le graphe
2026-10-14 11:47:19 +02:00
2026-10-14 11:50:31 +02:00
### C2
2026-10-14 11:47:19 +02:00
![C2](./C2.png)
2026-10-14 11:50:31 +02:00
### C4
2026-10-14 11:47:19 +02:00
![C4](./C4.png)
2026-10-14 11:50:31 +02:00
### P2
2026-10-14 11:47:19 +02:00
![P2](./P2.png)
2026-10-14 11:50:31 +02:00
### P3
2026-10-14 11:47:19 +02:00
![P3](./P3.png)
2026-10-14 11:50:31 +02:00
### J2
2026-10-14 11:47:19 +02:00
![J2](./J2.png)
2026-10-14 11:50:31 +02:00
### J6
2026-10-14 11:47:19 +02:00
![J6](./J6.png)
2026-10-14 12:00:22 +02:00
## 2. Compter les décisions
2026-10-14 11:47:19 +02:00
2026-10-14 12:00:22 +02:00
### J1-J6
2026-10-14 12:20:54 +02:00
- [ ] J1 = 1
- [ ] J2 = 2 + 1 = 3
- [ ] J3 = 7 + 1 = 8
- [ ] J4 = 8 + 1 = 9
- [ ] J5 = 10 + 1 = 11
- [ ] J6 = 8 + 1 = 9
2026-10-14 12:00:22 +02:00
### C1-C6
2026-10-14 12:20:54 +02:00
- [ ] C1 = 1
- [ ] C2 = 2 + 1 = 3
- [ ] C3 = 2 + 1 = 3
- [ ] C4 = 7 + 1 = 8
- [ ] C5 = 7 + 1 = 8
- [ ] C6 = 10 + 1 = 11
2026-10-14 12:00:22 +02:00
### P1-P5
2026-10-14 12:20:54 +02:00
- [ ] P1 = 1
- [ ] P2 = 2 + 1 = 3
- [ ] P3 = 2 + 1 = 3
- [ ] P4 = 2 + 1 = 3
- [ ] P5 = 13 + 1 = 14
2026-10-14 12:00:22 +02:00
2026-10-14 12:20:54 +02:00
### Complexité max : P5 = 14
2026-10-14 12:00:22 +02:00
## 3. Classer
2026-10-14 11:47:19 +02:00
2026-10-14 11:50:31 +02:00
- [ ] C1 -> <span style="color:blue"> simple </span>
2026-10-14 11:51:57 +02:00
- [ ] C2 -> <span style="color:blue"> simple </span>
- [ ] C3 -> <span style="color:blue"> simple </span>
- [ ] C4 -> <span style="color:yellow"> moyen </span>
- [ ] C5 -> <span style="color:yellow"> moyen </span>
- [ ] C6 -> <span style="color:red"> complexe </span>
2026-10-14 11:47:19 +02:00
2026-10-14 11:51:57 +02:00
- [ ] J1 -> <span style="color:blue"> simple </span>
- [ ] J2 -> <span style="color:blue"> simple </span>
- [ ] J3 -> <span style="color:red"> complexe </span>
- [ ] J4 -> <span style="color:red"> complexe </span>
- [ ] J5 -> <span style="color:red"> complexe </span>
- [ ] J6 -> <span style="color:red"> complexe </span>
2026-10-14 11:47:19 +02:00
2026-10-14 11:51:57 +02:00
- [ ] P1 -> <span style="color:blue"> simple </span>
- [ ] P2 -> <span style="color:blue"> simple </span>
- [ ] P3 -> <span style="color:yellow"> moyen </span>
- [ ] P4 -> <span style="color:yellow"> moyen </span>
- [ ] P5 -> <span style="color:red"> complexe </span>
2026-10-14 11:47:19 +02:00
2026-10-14 12:00:22 +02:00
## 4. Justifier les cas particuliers
2026-10-14 11:47:19 +02:00
2026-10-14 12:00:22 +02:00
### C3
2026-10-14 12:01:24 +02:00
```
2026-10-14 12:00:22 +02:00
return (annee % 4 == 0 && annee % 100 != 0) || annee % 400 == 0;
2026-10-14 12:01:24 +02:00
```
2026-10-14 12:00:22 +02:00
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.
2026-10-14 12:20:54 +02:00
## 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
2026-10-14 12:24:14 +02:00
```
### Complexité max de analyser_mot_de_passe : P5 = 5