Problem A: A Password Policy Requirement
Password security is a tricky issue. Users usually prefer short and simple passwords that are easy to remember, but such passwords are not secure enough. So, there should be some password policy requirements in security-enhanced environments. Below is an example of a password policy requirement for a user account in a domain:
The password should be at least six characters in length and should contain characters from all the following categories:
1) English uppercase letters (A through Z)
2) English lowercase letters (a through z)
3) Base 10 digits (0 through 9)
Given a string of alphanumeric (lower case, upper case, or digit) characters, your task is to find the length of its shortest contiguous substring which satisfies the above password policy requirement stated.
Input (Standard Input)
The input contains 𝑁𝑁 test cases. The first line of the input has one integer 𝑁𝑁 (1≤𝑁𝑁≤50).
Each of the next 𝑁𝑁 lines is a test case having a string of at most 200 alphanumeric characters.
Output (Standard Output)
Write the result of the 𝑖𝑖Pth test case, on the 𝑖𝑖Pth
line of output. You should just write one integer indicating the minimum length of a contiguous substring which satisfies the password policy. If there is no such substring, write “0”.
Sample Input and Output
Standard Input
Standard Output
4
AliKam123test
AbCdEfG
88syadneerG
Windows7released21october2009
6
0
10
8