0
[Code coach] password validator | 1 failed test case
Here's my attempt at solving one of the hard challenges, seems to work but only 7/8 test cases pass. Can anyone help me find/figure out what causes it? And at the same time provide a critique on what I can do better with my code https://code.sololearn.com/cpP7oC7f1gTp/?ref=app
3 Answers
+ 7
line 32 use && instead of ||. Because this condition always returns true.
+ 1
That makes sense thanks!
0
Do not get me wrong ! i am no expert but can you not use :
return (chr == '!' ||chr== '@' ||chr== '#' ||chr= '#x27; ||chr == '%' ||chr =='&' ||chr =='*')? 1:0;
in function:
validate_char(char chr)
or may be use a for loop to iterate ch arr[] = {'!','@','#','#x27;,'%' ,'&' ,'*'}; and check if(chr == arr[i];