-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStrong Password
46 lines (35 loc) · 974 Bytes
/
Strong Password
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
#include <bits/stdc++.h>
using namespace std;
// Complete the minimumNumber function below.
int minimumNumber(int n, string password) {
int con = 0;
//bool digit = false, low = false, upp = false, spec = false;
bool a[4] = {false};
for(int i = 0; i < n; i++){
if(password[i] >= 'A' && password[i] <= 'Z')
a[2] = true;
else if(password[i] >= 'a' && password[i] <= 'z')
a[1] = true;
else if(password[i] >= '0' && password[i] <= '9')
a[0] = true;
else
a[3] = true;
}
for(int i = 0; i < 4; i++)
if(!a[i])
con++;
return max(con, 6 - n);
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int n;
cin >> n;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
string password;
getline(cin, password);
int answer = minimumNumber(n, password);
fout << answer << "\n";
fout.close();
return 0;
}