-
Notifications
You must be signed in to change notification settings - Fork 6
/
Solution.cs
69 lines (49 loc) · 1.63 KB
/
Solution.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
class Solution
{
static void Main(string[] args)
{
var extraChars = 0;
var digitOccured = false;
var lowerCaseOccured = false;
var upperCaseOccured = false;
var specialCharsOccured = false;
var desiredLength = 0;
Console.ReadLine();
var nextChar = Console.Read();
while (nextChar != -1)
{
if (nextChar >= 48 && nextChar <= 57)
digitOccured = true;
if (nextChar >= 97 && nextChar <= 122)
lowerCaseOccured = true;
if (nextChar >= 65 && nextChar <= 90)
upperCaseOccured = true;
if (nextChar == 33
|| nextChar == 64
|| nextChar == 94
|| nextChar == 45
) //!@^-
specialCharsOccured = true;
if (nextChar >= 35 && nextChar <= 38) //#$%&
specialCharsOccured = true;
if (nextChar >= 40 && nextChar <= 43) //()*+
specialCharsOccured = true;
desiredLength++;
if (digitOccured && lowerCaseOccured && upperCaseOccured && specialCharsOccured && desiredLength >= 6)
break;
nextChar = Console.Read();
}
if (!digitOccured)
extraChars++;
if (!lowerCaseOccured)
extraChars++;
if (!upperCaseOccured)
extraChars++;
if (!specialCharsOccured)
extraChars++;
if (desiredLength + extraChars < 6)
extraChars += 6 - extraChars - desiredLength;
Console.WriteLine(extraChars);
}
}