Sort by

recency

|

491 Discussions

|

  • + 0 comments
    import re
    pattern = r'[789]\d{9}'
    print('\n'.join("YES" if bool(re.fullmatch(pattern,input())) else "NO" for _ in range(int(input()))))
    
  • + 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")
    
  • + 1 comment

    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:]))