Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views5 pages

Coding Question - 3rd Set

Uploaded by

Pavithra KS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Coding Question - 3rd Set

Uploaded by

Pavithra KS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Password format verifier – Q3

Applications and websites are usually secured using user id and


passwords. Such systems specify various rules while creating a new
password to ensure that it is complex and cannot be hacked easily.
One such system enforces the following rules while creating a new
password:
 The password should contain at least one lowercase letter (a-z)
 The password should contain at least one uppercase letter (A-Z)
 The password should contain at least one number (0-9)
 The password should contain at least one special character
 The total length of the password should be at least 10, but less than
32
 The password should not have the same character appearing more
than three times consecutively
The new password has a valid format only if it satisfies all the given
rules.
Given the password, print if its format is Valid or Invalid
Examples
E.g 1) Consider the new password Aa@1qwerty
This password has a valid format, because all the rules are satisfied:
 There are more than one lowercase letters
 There is one uppercase letter
 There is one number
 There is one special character
 The length is 10, which is minimum allowed length
 There are no consecutive repeating characters
Hence, the output would be Valid
E.g 2) Consider the new password Aa@1q2222y
This password has an Invalid format, because the following rule is
broken: The password should not have the same character appearing
more than three times consecutively
Here the character ‘2’ consecutively repeats four times
Hence, the output would be Invalid
E.g 3) Consider the new password Aa@1q222y
This password has a valid format, since all the rules are satisfied here.
The character ‘2’ is repeated consecutively, but only three times, which
is the maximum number of times allowed as per rules.
Hence, the output would be Valid

Function Description
Complete the function verifyPasswordFoemat in the editor below. The
function should print if the provided password is Valid or Invalid as per
the rules mentioned above
verifyPasswordFormat has the following parameter:
password: a String denoting the new password
Constraints
 The password length should be at least 10 and not more than 32
Input Format For Custom Testing
The first line contains a string denoting the password to be checked
Sample case 0
Sample Input For Custom Testing
Aa@1qwerty
Sample Output
Valid
Explanation
The given password satisfies all the rules: it has at least one lowercase
character, at least one uppercase character, at least one number, at least
one special character, the length is within the specified limits, and there
are no characters that repeat consecutively more than 3 times (in fact
this example has no consecutive repeating characters)
Sample case 1
Sample Input For Custom Testing
Aa@1q2222y
Sample Output
Invalid
Explanation
This password has an individual format since the last rule is broken here:
the character ‘2’ is repeated consecutively four times, which is more than
the maximum allowed limit of three repeatations.
Sample case 2
Sample Input For Custom Testing
Aa@1qwertyuioplkjhgfdsazxcvbnm
Sample Output
Invalid
Explanation
This password has an individual format since the length of the password
exceeds the maximum length that is allowed
C Language
#include<->
Char* readline( );

/* complete the ‘verifyPasswordFormat’ function below.


*
* The function accepts STRING password as parameter.
*/
void verifyPasswordFormat (char* password) {
}
Test Case 0
Input Expected Output
Aa@1qwerty Valid

Test Case 1
Input Expected Output
Aa@1qwert Invalid

Test Case 2
Input Expected Output
Aa@1qwertyuiopl@!@gfdsazxcvbnm$ Valid
Test Case 3
Input Expected Output
Aa@1qwertyuioplkjhgfdsazxcvbnm,,#$%12 Invalid

Test Case 4
Input Expected Output
Aa@yqwerty Invalid
Test Case 5
Input Expected Output
Aa01qwerty Invalid

Test Case 6
Input Expected Output
A3@1QWERTY Invalid

Test Case 7
Input Expected Output
6a@1qwerty Invalid

Test Case 8
Input Expected Output
Aa@1q222ty Valid

Test Case 9
Input Expected Output
Aa@1q2222y Invalid

Test Case 10
Input Expected Output
zF@1q22e33%%%@@@@ Invalid

You might also like