+ 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=app8 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
+ 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
+ 5
Minho 🇰🇷 got it thanks
+ 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;
}
+ 2
Thanks Arsenic . How i couldn't see that simple mistake🙄
+ 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')
+ 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
+ 1
Please tell me why my code is not working and what changes i should make to make it working.