forked from arsho/Hackerrank_Python_Domain_Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValidatingUID.py
23 lines (23 loc) · 845 Bytes
/
ValidatingUID.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'''
Title : Validating UID
Subdomain : Regex and Parsing
Domain : Python
Author : Ahmedur Rahman Shovon
Created : 15 July 2016
'''
import re
n = int(input())
upper_check = r'.*([A-Z].*){2,}'
digit_check = r'.*([0-9].*){3,}'
alphanumeric_and_length_check = r'([A-Za-z0-9]){10}$'
repeat_check = r'.*(.).*\1'
for i in range(n):
uid_string = input().strip()
upper_check_result = bool(re.match(upper_check,uid_string))
digit_check_result = bool(re.match(digit_check,uid_string))
alphanumeric_and_length_check_result = bool(re.match(alphanumeric_and_length_check,uid_string))
repeat_check_result = bool(re.match(repeat_check,uid_string))
if upper_check_result and digit_check_result and alphanumeric_and_length_check_result and not repeat_check_result:
print('Valid')
else:
print('Invalid')