Example Input: +15555555555 Output: SMS Input: 15555555555 Output: SMS Input: +15555555555555555 Output: INVALID_ADDRESS Input: whatsapp:15555555555 Output: WHATSAPP Input: wechat:identifier:ghke83772 Output: INVALID_ADDRESS Input: wechat:ghke83772 Output: WECHAT Input: whatsapp: +15555555555 Output: WHATSAPP Input: messenger:15555555555 Output: MESSENGER Input: messenger:+15555555555 Output: MESSENGER Input: messenger: +15555555555555555 Output: INVALID_ADDRESS Input: whatsapp:this_is_not_an_E164_number Output: INVALID_ADDRESS Input: messenger: this_is_not_an_E164_number Output: INVALID_ADDRESS Input: wechat:this_is_alphanumeric_with_special_character Output: WECHAT
Example Input: +15555555555 Output: SMS Input: 15555555555 Output: SMS Input: +15555555555555555 Output: INVALID_ADDRESS Input: whatsapp:15555555555 Output: WHATSAPP Input: wechat:identifier:ghke83772 Output: INVALID_ADDRESS Input: wechat:ghke83772 Output: WECHAT Input: whatsapp: +15555555555 Output: WHATSAPP Input: messenger:15555555555 Output: MESSENGER Input: messenger:+15555555555 Output: MESSENGER Input: messenger: +15555555555555555 Output: INVALID_ADDRESS Input: whatsapp:this_is_not_an_E164_number Output: INVALID_ADDRESS Input: messenger: this_is_not_an_E164_number Output: INVALID_ADDRESS Input: wechat:this_is_alphanumeric_with_special_character Output: WECHAT
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
Related questions
Question
Example
Input: +15555555555 Output: SMS
Input: 15555555555 Output: SMS
Input: +15555555555555555 Output: INVALID_ADDRESS
Input: whatsapp:15555555555 Output: WHATSAPP
Input: wechat:identifier:ghke83772 Output: INVALID_ADDRESS
Input: wechat:ghke83772 Output: WECHAT
Input: whatsapp: +15555555555 Output: WHATSAPP
Input: messenger:15555555555 Output: MESSENGER
Input: messenger:+15555555555 Output: MESSENGER
Input: messenger: +15555555555555555 Output: INVALID_ADDRESS
Input: whatsapp:this_is_not_an_E164_number Output: INVALID_ADDRESS
Input: messenger: this_is_not_an_E164_number Output: INVALID_ADDRESS
Input: wechat:this_is_alphanumeric_with_special_character Output: WECHAT

Transcribed Image Text:Given:
• address: A string containing the telephone number or
provider:identifier channel string
Write:
• A function that validates the address and returns where to route
the message to
The return value will be one of:
O For address strings with invalid formatting. return
"INVALID_ADDRESS"
o For valid E.164 format addresses, return "SMS"
O For other channels, return the provider string as
"WHATSAPP", "WECHAT", or "MESSENGER"
Constraints
• The address will be a string between 1- 258 characters long
• E.164 numbers
• May optionally start with '+'
o Will have up to 15 digits in length (not including the +')
o Digits can be between 0-9. The first digit can never be 0.
• Other channel addresses
• No whitespace allowed
• The provider and identifier will always be separated by one
colon {provider}:{identifier}
o Valid providers are: whatsapp, wechat, and messenger
· Inputs could be lower or upper case, but outputs should
always be uppercase
o Valid identifiers
· Identifiers are between 1 and 248 characters long
whatsapp and messenger identifiers must specifically
be E.164 numbers

Transcribed Image Text:2. What's in a number?
Prompt
What's in a number? In addition to using typical "addresses" (i.e.
phone numbers) for SMS messages, Twilio supports sending
messages through different channels such as wechat, whatsapp
and messenger. These other channels have their own address
formats.
Twilio uses a standardized phone number format for SMS
messages called E.164 phone numbers.
Some examples of valid E.164 numbers are:
• +15555555555
• +34864683619
• +61491570156
• 913858210056
For other channels messaging, they have addresses that are
formatted differently to indicate the provider responsible to
route the message to.
Some examples of these provider/identifier combinations are:
• whatsapp:34864683619
• messenger:+12025550001
• wechat:gh_a1f37dacefe3
All these values are passed around as strings. It is important
that we validate the format is correct for these addresses, as
well as identify the appropriate provider to route the message
to.
We are asking you to build a function that validates that the
address (which is either a standard phone number, or a
provider/identifier combo) is formatted correctly, and then
returns which channel to route the message to.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education