ECOO '12 R2 P2 - Password Strength

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Problem type

Passwords are the most basic information protection devices. But many people compromise the security of their data by choosing passwords that are easy for a human or a bot to guess. The table below summarizes one set of criteria for determining the strength of a password, and shows how to apply these criteria to two different example passwords.

Example 1: ECOO()123abcd9876 Example 2: 1234512345

Score Description Ex 1 Ex 2
Length Score 4 points for each character in the password. +68 +40
Basic Requirements To qualify, must be at least 8 chars long and also contain 3 of the four basic character types (upper case letters, lower case letters, digits, and symbols^*). Score two points for the length plus another two for each of the four types of characters it contains. +10 --
Upper Case Add (\text{length} - n) \times 2, where n is the number of upper case letters and n > 0. +26 --
Lower Case Add (\text{length} - n) \times 2, where n is the number of lower case letters and n > 0. +26 --
Digits Add 4 \times n, where n is the number of digits, but only if n < \text{length}. +28 --
Symbols Add 6 \times n, where n is the number of symbol characters. +12 --
Middle Digits and Symbols Add 2 \times n, where n is the number of digits and symbols not in the first or last position. +16 +16
Letters Only If the password contains only letters, subtract 1 point for each letter. -- --
Digits Only If the password contains only digits, subtract 1 point for each digit. -- -10
Consecutive Upper Case Subtract 2 \times (n - 1) for each set of n consecutive upper case characters. -6 --
Consecutive Lower Case Subtract 2 \times (n - 1) for each set of n consecutive lower case characters. -6 --
Consecutive Digits Subtract 2 \times (n - 1) for each set of n consecutive digits. -10 -18
Sequential Letters Subtract 3 \times (n - 2), where n is the length of the longest case-sensitive sequence of letters longer than 2 (e.g. abcd or CBA but not aBcD or SJD or a). -6 --
Sequential Digits Subtract 3 \times (n - 2), where n is the length of the longest sequence of digits longer than 2 (e.g. 9876 but not 28 or 6). -6 -9
TOTAL SCORE Add up all the above. Negative scores become 0. Scores over 100 become 100.
0-20 = Very Weak, 21-40 = Weak, 41-60 = Good, 61-80 = Strong, 81-100 = Very Strong
100
Very
Stong
19
Very
Weak
^* A symbol is any character that is not a letter or digit.

The input contains ten passwords, one per line. Write a program that reads each password, computes its total score based on the above criteria, and categorizes the password as Very Weak, Weak, Good, Strong, or Very Strong.

Sample Input

ECOO()123abcd9876
1234512345
ecoo2012

Sample Output

Very Strong (score = 100)
Very Weak (score = 19)
Good (score = 47)

Note: Only 3 cases are shown in this sample.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments


  • 2
    Infernape77  commented on Sept. 24, 2017, 4:18 p.m.

    All the sample inputs for my code output correctly, but I still don't pass all the test cases, can somebody give me a hint of where the mistake is for my code