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

1st Jan 2020, 3:45 AM
0x6176696c61
0x6176696c61 - avatar
3 ответов
+ 7
line 32 use && instead of ||. Because this condition always returns true.
1st Jan 2020, 3:51 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
That makes sense thanks!
1st Jan 2020, 5:16 AM
0x6176696c61
0x6176696c61 - avatar
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];
29th Dec 2022, 1:35 PM
Gaurav Kaushik