Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 18 additions & 25 deletions algorithms/strong-password.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/python3

import math
import os
import random
import re
import sys

numbers = "0123456789"
Expand All @@ -12,33 +8,30 @@
special_characters = "!@#$%^&*()-+"

def minimumNumber(n, password):
res = 0

if not any(x in numbers for x in password):
res += 1

if not any(x in lower_case for x in password):
res += 1

if not any(x in upper_case for x in password):
res += 1
numbers = "0123456789"
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
special_characters = "!@#$%^&*()-+"

if not any(x in special_characters for x in password):
res += 1
res = 0

if len(password) < 6:
return max(res, 6 - len(password))

return res
n_bool = 1
l_bool = 1
u_bool = 1
s_bool = 1
for c in password:
if c in numbers: n_bool = 0
elif c in lower_case: l_bool = 0
elif c in upper_case: u_bool = 0
elif c in special_characters: s_bool = 0
return max(6-n, n_bool + l_bool + u_bool + s_bool)


if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')


n = int(input())
n = int(input().strip())
password = input()

answer = minimumNumber(n, password)

fptr.write(str(answer) + '\n')
fptr.close()
print(answer)