+ 1

Help to to find problem in my code (password validator) it is not satisfying only one test case.

I tried many changes to satisfy all conditions still 1 test case is still failed so please tell me the required changes in to do. Conditions: Password should have atleast 2 number Password should have atleast 2 symbol from @#

amp;!*% Password should have atleast 7 characters https://code.sololearn.com/cDzlmIeTWPU3/?ref=app

21st Jan 2021, 8:59 AM
Raj Shivnandan Mishra
Raj Shivnandan Mishra - avatar
8 Antworten
+ 7
Your code is not displaying anything if the password entered is of length less than 7 characters. You can fix it with a simple else statement at the end👇 https://code.sololearn.com/c0YQ8Imfsnao/?ref=app
21st Jan 2021, 9:25 AM
Arsenic
Arsenic - avatar
+ 5
Raj Shivnandan Mishra What happens when if(strlen(takepass)<7) ? You didn't handle that case and that's why test case 4 didn't pass. P.S. you also don't need to count all the alphabets.. The lines 8 - 9 and 27 -34 are unnecessary. S†ʒphʒŋ I know your intention was to help but please don't post code snippets without explaining the error in OP's code. Please follow the guidelines 👇 https://www.sololearn.com/post/797292/?ref=app
21st Jan 2021, 9:25 AM
Minho
Minho - avatar
+ 5
Minho 🇰🇷 got it thanks
22nd Jan 2021, 8:20 AM
VṢtēphen
VṢtēphen - avatar
+ 3
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { int n=0,i=0,num=0,spl=0; char pwd[30]={}; scanf("%s",pwd); n=strlen(pwd); for(i=n-1;i>=0;i--) { if(isspace(pwd[i])) {continue;} if(isdigit(pwd[i])) {num=num+1;continue;} if((pwd[i]=='#')||(pwd[i]=='@')||(pwd[i]=='!')||(pwd[i]=='
#x27;)||(pwd[i]=='%')||(pwd[i]=='&')|| (pwd[i]=='*')||(pwd[i]=='^')) {spl=spl+1;continue;} } if((num>=2) && (spl>=2) && (n>=7)) printf("Strong"); else printf("Weak"); return 0; }
21st Jan 2021, 9:04 AM
VṢtēphen
VṢtēphen - avatar
+ 2
Thanks Arsenic . How i couldn't see that simple mistake🙄
21st Jan 2021, 9:39 AM
Raj Shivnandan Mishra
Raj Shivnandan Mishra - avatar
+ 2
d = ['!', '@', '#', '
#x27;, '%', '&', '*'] e = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] s = str(input()) if len(s) < 7: print('Weak') else: k = j = 0 a = [] for i in range(len(s)): if s[i] in d : k += 1 if s[i] in e : j += 1 if k >= 2 and j >= 2: print('Strong') else: print('Weak')
22nd Jan 2021, 8:17 AM
Dipayan Dasgupta
Dipayan Dasgupta - avatar
+ 2
d = ['!', '@', '#', '
#x27;, '%', '&', '*'] e = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] s = str(input()) if len(s) < 7: print('Weak') else: k = j = 0 a = [] for i in range(len(s)): if s[i] in d : k += 1 if s[i] in e : j += 1 if k >= 2 and j >= 2: print('Strong') else: print('Weak') #simple solution
22nd Jan 2021, 8:18 AM
Dipayan Dasgupta
Dipayan Dasgupta - avatar
+ 1
Please tell me why my code is not working and what changes i should make to make it working.
21st Jan 2021, 9:08 AM
Raj Shivnandan Mishra
Raj Shivnandan Mishra - avatar