Sign in to track progress, unlock prep layers, and browse your pipeline.Sign in
Validate password and list rule violations
Problem Description
You are tasked with validating a given password string against a predefined set of rules. Your function should identify and return all rules that the password violates.
Validation Rules
- Length: The password must be strictly greater than 15 characters.
- Substring Exclusion: The password must not contain the substring "password", case-insensitive. For example, "MyPassWord123" would violate this rule.
- Case Diversity: The password must contain at least one uppercase letter (A-Z) and at least one lowercase letter (a-z).
- Special Characters: The password must contain at least one character from a provided set of exactly three special symbols (e.g.,
{'!', '@', '#'}). - Consecutive Character Limit: No single character may repeat more than 4 times consecutively. For instance, "aaaaa" violates this rule, while "aaaa" is acceptable.
Input
p: The password string to be validated.special_symbols: A set or list containing exactly three allowed special characters.
Output
- A list of identifiers (e.g., strings or numerical codes) corresponding to all rules that the password violates. The order of these identifiers in the output list should be deterministic (e.g., sorted by rule number).
Notes
- If the password string is fully compliant with all rules, an empty list should be returned.
- The "password" substring check should be performed case-insensitively.
AI interview prep
Core dilemma
Designing a robust, performant, and extensible validation engine capable of applying multiple distinct string rules, while ensuring comprehensive error reporting and handling diverse edge cases.
Mid-level signals3
Senior signals3
Red flags3
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Validate password and list rule violations
Problem Description
You are tasked with validating a given password string against a predefined set of rules. Your function should identify and return all rules that the password violates.
Validation Rules
- Length: The password must be strictly greater than 15 characters.
- Substring Exclusion: The password must not contain the substring "password", case-insensitive. For example, "MyPassWord123" would violate this rule.
- Case Diversity: The password must contain at least one uppercase letter (A-Z) and at least one lowercase letter (a-z).
- Special Characters: The password must contain at least one character from a provided set of exactly three special symbols (e.g.,
{'!', '@', '#'}). - Consecutive Character Limit: No single character may repeat more than 4 times consecutively. For instance, "aaaaa" violates this rule, while "aaaa" is acceptable.
Input
p: The password string to be validated.special_symbols: A set or list containing exactly three allowed special characters.
Output
- A list of identifiers (e.g., strings or numerical codes) corresponding to all rules that the password violates. The order of these identifiers in the output list should be deterministic (e.g., sorted by rule number).
Notes
- If the password string is fully compliant with all rules, an empty list should be returned.
- The "password" substring check should be performed case-insensitively.