Sort by

recency

|

320 Discussions

|

  • + 0 comments

    My second hard problem <3.

    LookAround operator are mandatory when we want to know the number of occurences. This is what we have to learn from this exercise, and also the back reference operators.

    Fortunately, the exercise with credit card, and valid UID train us for that. So it was fluid to continue with this problem.

    regex_integer_in_range = r"^[1-9][0-9]{5}$"	# Do not delete 'r'.
    regex_alternating_repetitive_digit_pair = r"(?=(\d)\d\1)"	# Do not delete 'r'.
    
    
    import re
    P = input()
    
    print (bool(re.match(regex_integer_in_range, P)) 
    and len(re.findall(regex_alternating_repetitive_digit_pair, P)) < 2)
    
  • + 0 comments

    Here is HackerRank Validating Postal Codes in Python solution - https://programmingoneonone.com/hackerrank-validating-postal-codes-solution-in-python.html

  • + 0 comments
    regex_integer_in_range = r"^[1-9]\d{5}$"	# Do not delete 'r'.
    regex_alternating_repetitive_digit_pair = r"(\d)(?=.\1)"	# Do not delete 'r'.
    # here we first check  the digit and then we skip the one  chracter which is symbolizes by dot . and after that we match the same  character which is written before skipped character
    
  • + 0 comments
    regex_integer_in_range = r"^[1-9][0-9][0-9][0-9][0-9][0-9]$"	# Do not delete 'r'.
    regex_alternating_repetitive_digit_pair = r"(?=(\d).{1}\1)"	# Do not delete 'r'.
    
  • + 2 comments

    I did it the dumb way but it works:

    regex_integer_in_range = r"^[1-9][0-9]{5}$" regex_alternating_repetitive_digit_pair = r"(?=(0.0|1.1|2.2|3.3|4.4|5.5|6.6|7.7|8.8|9.9))"