easy +10 pts

Validate Password Strength

Check passwords against length, character variety, and common patterns.

Write a function `validate_password(password: str) -> bool` that returns `True` if the password is strong, otherwise `False`. A password is considered strong if it satisfies **all** of the following rules: 1. **Length**: between 8 and 20 characters inclusive. 2. **Character variety**: contains at least one uppercase letter, one lowercase letter, one digit, and one special character (special characters are any of `!@#$%^&*`). 3. **No whitespace**: does not contain any whitespace characters (space, tab, newline, etc.). 4. **No common pattern**: does not contain the substring `'123'`, `'abc'`, `'password'`, or `'qwerty'` (case-insensitive). Note: The function should handle empty strings gracefully and should not assume any other characters are special.

Constraints

- `password` is a string of any length (including empty string). - The function must run in O(n) time where n is the length of the string.

Example

```python
validate_password("StrongP@ss1")   # True
validate_password("weak")           # False (too short)
validate_password("NoSpecial1")     # False (no special char)
validate_password("NoDigit@bc")     # False (no digit)
validate_password("UPPERlower123!") # False (contains '123')
```
10 points ~15 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use string methods like `.isupper()`, `.islower()`, `.isdigit()` to check character types.
For the special characters, create a set of allowed specials and check membership.
To check whitespace, iterate through characters and use `.isspace()`.
For the common patterns, convert the password to lowercase and check if any of the substrings are present.
Combine all conditions with `and` and return the result.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.