-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validating-UID.py
30 lines (26 loc) · 910 Bytes
/
Validating-UID.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
#Problem
"""
ABCXYZ company has up to 100 employees.
The company decides to create a unique identification number (UID) for each of its employees.
The company has assigned you the task of validating all the randomly generated UIDs.
A valid UID must follow the rules below:
It must contain at least 2 uppercase English alphabet characters.
It must contain at least 3 digits (0 - 9).
It should only contain alphanumeric characters (a - z, A - Z & 0 - 9).
No character should repeat.
There must be exactly 10 characters in a valid UID.
"""
#Code
import re
for i in range(int(input())):
UID = ''.join(sorted(input()))
try:
assert re.search(r'[A-Z]{2}', UID)
assert re.search(r'\d\d\d', UID)
assert not re.search(r'[^a-zA-Z0-9]', UID)
assert not re.search(r'(.)\1', UID)
assert len(UID) == 10
except:
print("Invalid")
else:
print("Valid")