問題
A password is strong if it has at least 8 characters, at least one uppercase letter, at least one lowercase letter and at least one digit (English letters and 0–9).
Implement is_strong_password(password).
Input
password: The password to check (ASCII characters).
Output
Return true if all rules hold, otherwise false.
制約
0 ≤ length of password ≤ 100
例
入力:
password = "Secret123"
期待される出力:
expected = True
入力:
std::string password = "Secret123";
期待される出力:
bool expected = true;
入力:
string password = "Secret123";
期待される出力:
bool expected = true;
解説
9 characters with uppercase S, lowercase letters and digits: strong.
入力:
password = "password1"
期待される出力:
expected = False
入力:
std::string password = "password1";
期待される出力:
bool expected = false;
入力:
string password = "password1";
期待される出力:
bool expected = false;
解説
There is no uppercase letter, so it is not strong.
解き方のヒント
まずは自分で考えてから、ヒントを 1 つずつ開いてみましょう。
ヒント 1
パスワードは複数の独立した条件をすべて満たす必要がある。
ヒント 2
長さを確認しながら、大文字・小文字・数字を見たかどうかを記録する。
ヒント 3
空文字や短すぎる文字列は、混在文字があっても即失格。
目安の計算量
時間 O(n)、追加メモリ O(1)
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。