Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Password Validation Rules

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Password Validation Rules. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Mistral Solutions firmware uses password validation before accepting credentials through an embedded configuration interface. Implement a validator that returns whether a password satisfies every required rule.

A password is valid if it:

  1. Contains at least one uppercase ASCII letter from A to Z.
  2. Contains at least one digit from 0 to 9.
  3. Contains at least one special character, defined as any character that is not an ASCII letter or digit.
  4. Does not contain consecutive identical characters. The comparison is case-sensitive, so aA is allowed but aa is not.

Formal Specification

Given a string password, return True if all rules are satisfied; otherwise, return False. The input contains printable ASCII characters only. A space counts as a special character.

Constraints

  • 1 <= len(password) <= 10^5
  • password contains only printable ASCII characters
  • Uppercase and lowercase characters are distinct
  • A space is treated as a special character

Function Signature

def validate_password(password):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output