Sort by

recency

|

490 Discussions

|

  • + 0 comments
    import re
    pattern=r"^[789]{1}\d{9}$"
    for _ in range(int(input())):
        if re.match(pattern,input()):
            print("YES")
        else:
            print("NO")
    
  • + 0 comments

    When we do the "Roman Number Problem" before, and this one after, it's like playing Elden Ring without mimic first, then play Elden Ring with mimic x).

    Here the code :

    import re
    N = int(input())
    
    for _ in range(N):
        current_number = input()
        
        pattern = r"^[789]{1}\d{9}$"
        
        yes_or_no = bool(re.match(pattern, current_number))
        
        if yes_or_no:
            print("YES")
        else:
            print("NO")
    
  • + 0 comments

    Without Regex:

    for i in range(int(input())):
        inp= input()
        
        if len(inp) == 10 and (inp.startswith('7') or inp.startswith('8') or inp.startswith('9')) and inp.isnumeric():
            print("YES")
        else:
            print("NO")
    				
    				
    
  • + 0 comments

    Strange to see such a simple challenge following a few that are more complex. I'm used to challenges being increasingly more complex.

    import re, sys
    
    print('\n'.join(
      ['NO', 'YES']
      [re.match(r'^[789]\d{9}$', l) is not None]
      for l in sys.stdin.readlines()[1:])) 
    
  • + 0 comments

    n = int(input()) # Read number of test cases

    for i in range(n):

    ph_no = input()  # Read each mobile number
    
    if len(ph_no) == 10 and ph_no[0] in ['7', '8', '9'] and ph_no.isdigit():
        print("YES")
    else:
        print("NO")