+ 1
Why test case number 8 is hidden in password validation challenge..
#include <bits/stdc++.h> using namespace std; void ps(string s){ int i,j=0; if(s.length()<7){ cout<<"Weak"; return; } for(i=0;i<s.length();i++){ if(isdigit(s[i]) || ispunct(s[i])){ j++; if(j>=4){ cout<<"Strong"; return; } } } cout<<"Weak"; return; } int main() { string s; cin>>s; ps(s); return 0; } this is my code for that problem its a code coach problem only 1 test case is not getting passed what is wrong I'm not understanding?
1 Antwort
+ 1
Your approach is wrong. The problem states that the password is valid (strong) if it has atleast two numbers and atleast two punctuations and is atleast 7 characters long. But according to your code it will print strong when there will be either 4 numbers or 4 punctuations.