-
Notifications
You must be signed in to change notification settings - Fork 0
/
Strong Password.py
46 lines (31 loc) · 987 Bytes
/
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
# https://www.hackerrank.com/challenges/strong-password/problem
# 14.03.2020
#!/bin/python3
import math
import os
import random
import re
import sys
numbers = "0123456789"
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
special_characters = "!@#$%^&*()-+"
def minimumNumber(n, password):
number, lower, upper, special = True, True, True, True
for letter in password:
if letter in numbers:
number = False
if letter in lower_case:
lower = False
if letter in upper_case:
upper = False
if letter in special_characters:
special = False
errors = number + lower + upper + special
return errors if n >= 6 else max(6 - n, errors)
# Return the minimum number of characters to make the password strong
if __name__ == '__main__':
n = int(input())
password = input()
answer = minimumNumber(n, password)
print(answer)