-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvaluid.py
42 lines (30 loc) · 798 Bytes
/
valuid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import re
def valid(uid):
'''Rules:
* Must contain at least 2 upper case letters
* Must contain at least 3 digits
* Must only contain alphanumberics
* No repeating characters
* Must be exactly 10 characters
'''
if len(re.findall(r'[A-Z]', uid)) < 2:
return False
if len(re.findall(r'\d', uid)) < 3:
return False
if len(re.findall(r'[^a-zA-Z\d]', uid)) > 0:
return False
if len(re.findall(r'([a-zA-Z\d]).*\1', uid)) > 0:
return False
if len(uid) != 10:
return False
return True
def main():
lines = int(input())
for _ in range(lines):
uid = input()
if valid(uid):
print('Valid')
else:
print('Invalid')
if __name__ == '__main__':
main()