Katkat

Validate password and list rule violations

KaratSoftware Engineer · Technical Screen

Last updated

This question evaluates string-processing and input-validation skills, including case-insensitive substring detection, character class checks, pattern matching for special symbols, and handling edge cases like consecutive character limits.

Problem

You are given a password string p. Validate it against a set of rules and return all rules that the password violates.

Rules

  1. Length must be greater than 15 characters.
  2. Must not contain the substring "password" (case-insensitive). For example, "MyPassWord123" violates this rule.
  3. Must contain at least one uppercase letter (A-Z) and at least one lowercase letter (a-z).
  4. Must contain at least one character from a given set of three special symbols (the set will be provided by the interviewer; e.g., {!, @, #}).
  5. No character may repeat more than 4 times consecutively (e.g., "aaaaa" violates; "aaaa" is OK).

Input

  • A string p.
  • A set/list of exactly 3 allowed special characters.

Output

  • A list of violated rules (as strings or codes) in a deterministic order (e.g., rule number order).

Notes

  • If the password is fully compliant, return an empty list.
  • Treat the "password" check as case-insensitive.