-
Notifications
You must be signed in to change notification settings - Fork 0
/
strong_password.py
50 lines (38 loc) · 1.08 KB
/
strong_password.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the minimumNumber function below.
def minimumNumber(n, password):
check = [0,0,0,0]
numbers = set("0123456789")
lower_case = set("abcdefghijklmnopqrstuvwxyz")
upper_case = set("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
special_characters = set("!@#$%^&*()-+")
for i in range(n):
if password[i] in numbers:
check[0] = 1
if password[i] in lower_case:
check[1] = 1
if password[i] in upper_case:
check[2] = 1
if password[i] in special_characters:
check[3] = 1
total = 0
for x in check:
if x == 0:
total += 1
if n < 6:
if total < 6-n:
total = 6-n
return total
# Return the minimum number of characters to make the password strong
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
password = input()
answer = minimumNumber(n, password)
fptr.write(str(answer) + '\n')
fptr.close()