/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 22ms 3.59 MiB

Code

# Import the re module for regular expressions
import re

# Define a function to check the validity of a password
def is_valid(password):
  # Use re.search to check if the password contains at least one lowercase letter
  if not re.search("[a-z]", password):
    return False
  # Use re.search to check if the password contains at least one uppercase letter
  if not re.search("[A-Z]", password):
    return False
  # Use re.search to check if the password contains at least one digit
  if not re.search("[0-9]", password):
    return False
  # Use re.search to check if the password contains at least one special character
  if not re.search("[!@#$%^&*()]", password):
    return False
  # Use len to check if the password has a minimum length of 8 characters
  if len(password) < 8:
    return False
  # If all the conditions are met, return True
  return True

# Take the input of the number of cases to check
T = int(input())

# Use a for loop to iterate over T times
for i in range(T):
  # Take the input of the password string
  password = input()
  # Call the validity function with the password string
  valid = is_valid(password)
  # Print the output accordingly
  if valid:
    print("valid")
  else:
    print("invalid")

Information

Submit By
Type
Submission
Problem
P1007 Password Checker
Language
Python 3 (Python 3.12.3)
Submit At
2024-01-09 14:17:25
Judged At
2024-01-09 14:17:25
Judged By
Score
100
Total Time
22ms
Peak Memory
3.59 MiB