Strong Password

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

A password is said to be strong if it satisfies all the following criteria:

  • It has at least 8 characters.
  • It contains at least one lowercase letter.
  • It contains at least one uppercase letter.
  • It contains at least one digit.
  • It contains at least one special character. The special characters are the characters in the following string: -!@#$%^&*()+.
  • It does not contain 2 of the same character in adjacent positions (i.e., "aab" violates this condition, but "aba" does not).

In this programming problem, you are required to write a function named is_strong that accepts a string and returns if it is a strong password or not (i.e. return a boolean value).

You can start with this template code and ensure your code can run correctly within this template:

from re import search

def is_strong(passwd):
    # your code here

# Note that the following code is for local testing purposes only. You should leave this part of code unchanged and not submit it to the OJ system.
T = int(input())
for t in range(T):
    passwd = input()
    if is_strong(passwd):
        print('Strong')
    else:
        print('Weak')

Please note that you only have to submit the definition of the is_strong function to the OJ system along with the import statement if you used the module. The rest of the code is for your local testing purposes only.

Input Specification

The first line of the input gives the number of test cases, T, and then T test cases follow.

For each test case, it will consist of a single line that contains a string of length n represents a password.

Constraints

1 \leq T \leq 100

1 \leq n \leq 30

Output Specification

For each test case, output a single line containing a string represents if the given password is strong or not.

Sample Input

3
ImStrong!
NeverGonnaLetYouDown-3-!
ILovePython2023!

Sample Output

Weak
Weak
Strong

Hint

regular expression


Comments

There are no comments at the moment.