+ 10
Line 10 if(isdigit(Password[index]!=0)) Should be if(isdigit(Password[index])!=0) Actually, should be if(isdigit(Password[index])) But I chose to stick with your style. And there is one case missing: What happens if the password does not have ANY special characters?
1st May 2022, 7:21 AM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 4
The code I am looking at? Line 10 has not yet been fixed there. If you are using a new code then post theupdated version, please.
1st May 2022, 10:14 AM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 4
You're welcome :) Glad that it is finally solved now ๐Ÿ‘ Out of curiosity I was working on it meself in C. The result of which is in my code bits. If you are curious, feel free to check it out :)
4th May 2022, 8:31 AM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 3
Yes, your algorithm is rather convoluted, I must say. However, which is the current version that is still not fixed?
1st May 2022, 1:42 PM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 2
Manav Roy What is your IsTwoNumbers() function do? What is the need of it? It always prints weak on a digit encounter at last digits....!
1st May 2022, 10:21 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
It seems to be working now.
1st May 2022, 6:01 PM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 2
I'll be unsubscribing since there is enough traffic on here. Please mention me if anyone wants to reach me :)
2nd May 2022, 10:14 AM
Ani Jona ๐Ÿ•Š
Ani Jona ๐Ÿ•Š - avatar
+ 2
#include<stdio.h> #include<string.h> int main(){ int i, n=0, m=0; char s[30]; scanf("%s",s); if(strlen(s) >= 7){ for(i=0; s[i]!='\0'; i++){ if(s[i]=='#'||s[i]=='
#x27;||s[i]=='%'||s[i]=='&'||s[i]=='*'||s[i]=='!'||s[i]=='@') ++n; if(s[i]=='0'||s[i]=='1'||s[i]=='2'||s[i]=='3'||s[i]=='4'||s[i]=='5'||s[i]=='6'||s[i]=='7'||s[i]=='8'||s[i]=='9') ++m; } } if(n>=2 && m>=2) printf("Strong"); else printf("Weak"); return 0; }
3rd May 2022, 1:33 AM
Vaibhav
Vaibhav - avatar
+ 2
Vaibhav Singh That's the C version.
3rd May 2022, 2:52 AM
Bob_Li
Bob_Li - avatar
+ 2
Bob_Li i know the task. Also about special characters, am saying same. Seems you not read my all replys.. Read by date sorted way, for clarity.. And also expecting that input don't have special characters other than specified in description. But Manav Roy code is taking all other into count. May it cause problem I thought but now I guess it won't affect. I just letting @Manav go on his own approach...
3rd May 2022, 9:17 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Bob_Li Yes about that also I mentioned more times.. His approach is isalpha(..)==0 && isdigit(..)== 0 means it's a special character... It works but he is having redudent checks..
3rd May 2022, 9:28 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Bob_Li Yes. That's why I said before "Task description asked to check special characters !@#$%&* but your also accouting other special character like +-_?.. So if input contains these characters then it may fail otherwise I think it works..." But I guess now, input don't have special characters other than mentioned in description I guess. So not efficient but this approach works.. I just letting Manav Roy go on his own approach firstfirst from start.
3rd May 2022, 9:34 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Manav Roy congrats.. Finally.. Hope you try to simplify it.. You're welcome..
4th May 2022, 9:43 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 2
Manav Roy Congratulations! You powered through it. In learning, the hard way is often more valuable than the easy way... and you took the hard path. Respect.
4th May 2022, 9:47 AM
Bob_Li
Bob_Li - avatar
+ 1
Manav Roy as you saying .. In IsTwoNumbers function,I basically checked if the password contains **two numbers or not." where are you checking two numbers or not? I can't find it.. It doing like : If input : 1a2 On '1' it calls function but on 'a' it returns back and breaking loop.. Else for ex: a1234 On 1 it calls function and and comes out loop after 4 and prints weak and exits.. . Why you need functions here..? Instead why don't you use a counter and just increment it's value.. after last check according to description just...
1st May 2022, 1:57 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Oh.. Wait. You want both to return 0.. .. No. Privious one is better.. Reply code works for single character.. But you need for all characters to check.. But why you using functions here instead of just a counter required.. It is more confusing..
1st May 2022, 3:08 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Use those in proper way , as it's purpose: isdigit - Returns 1 if a character is digit. isalpha - Returns 1 if a character is an alphabet . Reverse way will isDigit(..) != 0 => on '9' , condition is true.. isDigit(..) == 0 => on '9' , condition is false.. Also On 'a' condition is false.. So use isdigit(.. ) == 1 Manav Roy before all actually, are you edited your code to @Ani Jona's suggestion to use ( isDigit(password[index] ) != 0 ) instead of (isDigit(password[index] != 0 ) ) ๐Ÿ‘ˆabout braces.. I thought you changed but seems like you are not saved the code after changing.. ?
1st May 2022, 3:37 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Task description asked to check special characters !@#$%&* but your also accouting other special character like +-_?.. So if input contains these characters then it may fail otherwise I think it works...
1st May 2022, 7:57 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Bob_Li I also saying the same.. Read my replies from start.. may you read only last one. @Manov code is working but taking count other special characters into count.. So i guess that may causing problem to fail test cases.. So suggestion is to take count those special characters only which described in description..
2nd May 2022, 10:17 AM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ
+ 1
Jayakrishna๐Ÿ‡ฎ๐Ÿ‡ณ I have read your replies and realize that you too have seen that Manav Roy was taking the long route to the solution. I just wanted to reinforce that point. I also admire Ani Jona ๐Ÿ•Š 's effort to make the code work. It can be fixed, but that would end up with a janky code that is not efficient at all.
2nd May 2022, 10:25 AM
Bob_Li
Bob_Li - avatar