Validating UID Hacker Rank Solution – Queslers

Problem : Validating UID Hacker Rank Solution

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.

Input Format :

The first line contains an integer T, the number of test cases.
The next T lines contains an employee’s UID.

Output Format :

For each test case, print ‘Valid’ if the UID is valid. Otherwise, print ‘Invalid’, on separate lines. Do not print the quotation marks.

Sample Input :

2
B1CD102354
B1CDEF2354

Sample Output :

Invalid
Valid

Explanation :

B1CD102354: 1 is repeating → Invalid
B1CDEF2354: Valid 

Validating UID Hacker Rank Solution in python 2

import re
for i in range(int(raw_input())):
    N = raw_input().strip()
    if N.isalnum() and len(N) == 10:
        if bool(re.search(r'(.*[A-Z]){2,}',N)) and bool(re.search(r'(.*[0-9]){3,}',N)):
            if re.search(r'.*(.).*\1+.*',N):
                print 'Invalid'
            else:
                print 'Valid'    
        else:
            print 'Invalid'
    else:
        print 'Invalid'

Validating UID Hacker Rank Solution in python 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re

for _ in range(int(input())):
    u = ''.join(sorted(input()))
    try:
        assert re.search(r'[A-Z]{2}', u)
        assert re.search(r'\d\d\d', u)
        assert not re.search(r'[^a-zA-Z0-9]', u)
        assert not re.search(r'(.)\1', u)
        assert len(u) == 10
    except:
        print('Invalid')
    else:
        print('Valid')

Validating UID Hacker Rank Solution in pypy

# Enter your code here. Read input from STDIN. Print output to STDOUT

ids = []
line_num = int(raw_input())
while line_num:
  ids.append(raw_input());
  line_num -= 1;

import re

for id in ids:
  chars_count = {char:id.count(char) for char in id}
  upper = 0
  not_alnum = 0;
  dig = 0;
  for ch in id:
    if ch.isupper(): upper += 1
    if not ch.isalnum(): not_alnum = 1;
    if ch.isdigit(): dig += 1;

  if len(id) != 10: print 'Invalid'
  elif len(set(chars_count.values())) != 1: print 'Invalid'
  elif upper < 2: print 'Invalid'
  elif dig < 3: print 'Invalid'
  elif not_alnum: print 'Invalid'
  else: print 'Valid'

Validating UID Hacker Rank Solution in pypy 3

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re

def valid_uid(uid):
    if len(re.findall(r"[A-Z]", uid)) < 2 or \
            len(re.findall(r"[0-9]", uid)) < 3 or \
            not re.match(r"[A-Za-z0-9]{10}$", uid) or \
            len(set(uid)) != len(uid):
        return False
    
    return True
    
n = int(input())
for _ in range(n):
    uid = input()
    if valid_uid(uid):
        print("Valid")
    else:
        print("Invalid")
Validating UID Hacker Rank Solution Review:

In our experience, we suggest you solve this VValidating UID Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Validating UID is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution

Validating UID Hacker Rank Solution Conclusion:

I hope this Validating UID Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Mini-Max Sum Hacker Rank Solution

String Validators Hacker Rank Solution

Text Alignment Hacker Rank solution

String validators Hacker Rank Solution

Staircase Hacker Rank Solution

Leave a Reply

Your email address will not be published.