Skip to main content
EasyAlgorithms & Data StructuresBuild

Password Strength Tagger

Implement `tag_password_strength(password)` that returns a strength label. Return `"invalid"` if the password contains any whitespace. Otherwise, count how many character categories appear: lowercase, uppercase, digit,...

What you will practice

PythonArrays & StringsStringsInput ValidationImplementation

Requirements

  • Whitespace makes the password invalid before any strength rules are applied.
  • Character categories are lowercase, uppercase, digit, and symbol.
  • A symbol is any non-whitespace ASCII character that is not a lowercase letter, uppercase letter, or digit.
  • `"medium"` is limited to passwords with length from 8 through 11 inclusive.
  • Valid passwords with length >= 12 still return `"weak"` unless they have at least 3 categories.

Starter files

main.pyEditable starter

What the judge checks

  • Runs in the python environment with the python-function runner.
  • Uses a 1000ms judge budget.
  • Behavior rules include: Whitespace Invalid, Categories, Labels.

Constraints

  • 0 <= len(password) <= 200
  • password may contain any ASCII characters

Example behavior

Input
password = "Abcdef12"
Output
"medium"

Length 8, contains uppercase, lowercase, and digits — 3 categories.

Input
password = "Abc 12345"
Output
"invalid"

Contains whitespace.

Follow-up

How would you change the rules so password strength can be configured with custom length thresholds and required category counts?