The strong password
- O(n) · Medium
- Full plan
- Python
- JavaScript
- strings
- booleans
- loops
Problem
Your bank wants a new password from you, and it won't take just any. Before you send it in, you'd like to check it yourself.
Write a function that takes the password, a string, and returns true if it is strong and false if it is not. It is strong when it meets all four rules at once: it is 8 characters long or more, and it has at least one uppercase letter, at least one lowercase letter and at least one digit from 0 to 9.
Every character counts toward the length, spaces and symbols included. But a symbol like !, # or - is not a letter: it counts neither as uppercase nor as lowercase. Letters go from a to z, and passwords have no accented letters.
"Harbor2024" is strong: 10 characters, an uppercase H, arbor in lowercase and digits. "harbor2024" is not, because it has no capital.
Examples
The one from the example
"Harbor2024" → true
Too short
"Sun7sea" → false
No digit
"Wonderful" → false
Nothing but digits
"12345678" → false
With spaces and symbols
"My dog: 3" → true
Besides these, the challenge has hidden tests that are revealed when you submit your solution.
You start with this
Python
def is_strong(password):
passJavaScript
function isStrong(password) {
}It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.