We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Python
  3. Regex and Parsing
  4. Validating Postal Codes
  5. Discussions

Validating Postal Codes

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 258 Discussions, By:

recency

Please Login in order to post a comment

  • dmitrius988
    1 day ago+ 0 comments

    ChatGPT and passed all tests:

    import re

    regex_integer_in_range = r"^[1-9][0-9]{5}$" regex_alternating_repetitive_digit_pair = r"(\d)(?=\d\1)"

    P = input()

    print(bool(re.match(regex_integer_in_range, P)) and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)

    0|
    Permalink
  • harshitrathore09
    3 days ago+ 0 comments

    regex_integer_in_range = r"^[1-9][\d]{5}$" # Do not delete 'r'. regex_alternating_repetitive_digit_pair = r"(\d)(?=\d\1)" # Do not delete 'r'.

    0|
    Permalink
  • lenongree
    3 weeks ago+ 1 comment
    regex_integer_in_range = r"^\d{6}$"
    regex_alternating_repetitive_digit_pair = r"(\d)(?=.\1)"	
    
    0|
    Permalink
  • kyua2324
    3 weeks ago+ 0 comments
    regex_integer_in_range = r"^[0-9]{6}$"
    regex_alternating_repetitive_digit_pair = r"(.)(?=.\1)"
    
    0|
    Permalink
  • bashiralam185
    4 weeks ago+ 0 comments

    You can find some usefull resources to practice your coding skills special related to machine learning form this website:

    -1|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy