You are viewing a single comment's thread. Return to all comments →
My Solution in C :
int isDigit(char ch){ return (ch>='0' && ch<='9')?1:0; } int isLower(char ch){ return (ch>='a' && ch<='z')?1:0; } int isUpper(char ch){ return (ch>='A' && ch<='Z')?1:0; } int minimumNumber(int n, char* password) { int has_digit = 0; int has_lowercase = 0; int has_uppercase = 0; int has_special = 0; char *pass = password; char special_chars[] = "!@#$%^&*()-+"; while(*pass){ if(isDigit(*pass)) has_digit=1; else if(isLower(*pass)) has_lowercase=1; else if(isUpper(*pass)) has_uppercase=1; else{ for(int i=0; i<strlen(special_chars);i++){ if(special_chars[i]==*pass){ has_special=1; break; } } } pass++; } int missing_types = 0; if (!has_digit) missing_types++; if (!has_lowercase) missing_types++; if (!has_uppercase) missing_types++; if (!has_special) missing_types++; int needed_for_length = 0; if (n < 6) { needed_for_length = 6 - n; } int max=0; if(needed_for_length>missing_types) max = needed_for_length; else max = missing_types; return max; }
`
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →
My Solution in C :
`