A valid postal code  have to fullfil both below requirements:  must be a number in the range from  to  inclusive.  must not contain more than one alternating repetitive digit pair. Alternating repetitive digits are digits which repeat immediately after the next digit. In other words, an alternating repetitive digit pair is formed by two equal digits that have just a single digit between them. For example: 121426#Here,1isanalternatingrepetitivedigit.523563#Here,NOdigitisanalternatingrepetitivedigit.552523#Here,both2and5arealternatingrepetitivedigits. Your task is to provide two regular expressions regex_integer_in_range and regex_alternating_repetitive_digit_pair. Where: regex_integer_in_range should match only integers range from  to  inclusive regex_alternating_repetitive_digit_pair should find alternating repetitive digits pairs in a given string. Both these regular expressions will be used by the provided code template to check if the input string  is a valid postal code using the following expression: (bool(re.match(regex_integer_in_range,P))andlen(re.findall(regex_alternating_repetitive_digit_pair,P))<2) Input Format Locked stub code in the editor reads a single string denoting  from stdin and uses provided expression and your regular expressions to validate if  is a valid postal code. Output Format You are not responsible for printing anything to stdout. Locked stub code in the editor does that. Sample Input 0 110000 Sample Output 0 False Explanation 0 1 1 0000 : (0, 0) and (0, 0) are two alternating digit pairs. Hence, it is an invalid postal code. Note: A score of  will be awarded for using 'if' conditions in your code. You have to pass all the testcases to get a positive score.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

A valid postal code  have to fullfil both below requirements:

  1.  must be a number in the range from  to  inclusive.
  2.  must not contain more than one alternating repetitive digit pair.

Alternating repetitive digits are digits which repeat immediately after the next digit. In other words, an alternating repetitive digit pair is formed by two equal digits that have just a single digit between them.

For example:

121426#Here,1isanalternatingrepetitivedigit.523563#Here,NOdigitisanalternatingrepetitivedigit.552523#Here,both2and5arealternatingrepetitivedigits.

Your task is to provide two regular expressions regex_integer_in_range and regex_alternating_repetitive_digit_pair. Where:

regex_integer_in_range should match only integers range from  to  inclusive

regex_alternating_repetitive_digit_pair should find alternating repetitive digits pairs in a given string.

Both these regular expressions will be used by the provided code template to check if the input string  is a valid postal code using the following expression:

(bool(re.match(regex_integer_in_range,P))andlen(re.findall(regex_alternating_repetitive_digit_pair,P))<2)

Input Format

Locked stub code in the editor reads a single string denoting  from stdin and uses provided expression and your regular expressions to validate if  is a valid postal code.

Output Format

You are not responsible for printing anything to stdout. Locked stub code in the editor does that.

Sample Input 0

110000

Sample Output 0

False

Explanation 0

1 1 0000 : (00) and (00) are two alternating digit pairs. Hence, it is an invalid postal code.

Note:
A score of  will be awarded for using 'if' conditions in your code.
You have to pass all the testcases to get a positive score.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education