Password check
InterviewTime limit2sMemory limit512 MB
For each of N passwords, report valid if it has a lowercase letter, uppercase letter, digit, symbol, and length at least 12, else invalid.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Dublin City University wants to stop students and staff from using weak passwords. The security department asked you to write a program that checks whether a password meets every quality requirement set by the password guidelines council.
The requirements are as follows. A password is strong enough when it has all of these properties:
- At least one lowercase letter.
- At least one uppercase letter.
- At least one digit.
- At least one symbol from the set
+_)(*&^%$#@!./,;{}. - Length at least 12.
For example, Aa1_ meets the first four requirements but is shorter than 12 characters. Aa1234567890_ meets every requirement.
Input
One input holds a batch of passwords to process.
The first line contains an integer , the number of passwords to process.
Each password is given on two lines. The first line contains an integer , the size of the password. The next line contains a sequence of characters, the password to check.
A password contains only the letters a to z (lowercase and uppercase), the digits 0 to 9, and the symbols +_)(*&^%$#@!./,;{}.
The size of a password is at most 30, and one input contains at most 100 passwords.
Output
For each password, write a line with valid if the password meets the quality requirements, or invalid otherwise. Keep the order in which the passwords were given.