Sort by

recency

|

566 Discussions

|

  • + 0 comments

    WHY TF ARE PEOPLE SOLVING A REGEX PROBLEM WITHOUT REGEX?

    import re
    
    REX = re.compile(r'^(?=(?:.*[A-Z]){2,})(?=(?:.*\d){3,})(?!.*(.).*\1)[A-Za-z0-9]{10}$')
    
    def checker(id):
        return "Valid" if REX.match(id) else "Invalid"
            
    if __name__=="__main__":
        N = int(input())
        for _ in range(N):
            print(checker(input().strip()))
    
  • + 0 comments
    def check_uid(uid):
        v='Invalid'
        if len(uid) == 10:
            if sum([0 if uid.count(i)==1 else 1 for i in uid])==0:
                if uid.isalnum():
                    if sum([1 if i.isdigit() else 0 for i in uid])>=3:
                        if sum([1 if i.isupper() else 0 for i in uid])>=2:
                            v='Valid'
        print(v)
            
    for _ in range(int(input())):
        check_uid(input())
        
    
  • + 0 comments

    import re

    pattern = r'^(?!.(.).\1)(?=(?:.[A-Z]){2,})(?=(?:.[0-9]){3,})[a-zA-Z0-9]{10}$'

    print(*["Valid" if bool(re.match(pattern, input())) else 'Invalid' for _ in range(int(input()))], sep = '\n')

  • + 0 comments

    why is this code not working, can someone explain why?

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import re 
    
    n = int(input())
    
    regPat = r'^(?=(.*[A-Z]){2,})(?=(.*\d){3,})(?!.*(.).*\1)[a-zA-Z0-9]{10}$'
    
    for _ in range(n):
        if re.match(regPat, input()):
            print("Valid")
        else:
            print("Invalid")
    
  • + 0 comments
    import re
    for _ in range(int(input())):
        uid = input()
        if len(re.findall(r'[A-Z]',uid)) >= 2 and len(re.findall(r'\d',uid)) >= 3 and uid.isalnum() and len(set(uid)) == 10:
            print("Valid")
            
        else:
            print("Invalid")