Answered step by step
Verified Expert Solution
Question
1 Approved Answer
answer in python language How to Attempt? Royal Morse Code The Royal British Kingdom has enforced a new decree in the society that all princes
answer in python language
How to Attempt? Royal Morse Code The Royal British Kingdom has enforced a new decree in the society that all princes and princesses must use a new form of Morse code for all communications. We know that Morse Code uses dots (.) and dashes (-) to communicate meaning to the receiver. The following rules are stated according to this decree: - Any message must begin with a dot (.) - Any message must end with a dash (-) - Every dot (.) must have a corresponding dash (-) after it to close it If a message follows all the mentioned rules, then it is considered compli with the Royal Decree and the message is allowed to be sent. Otherwise considered as defaulted. The Great Prince of Britain has sent out a set of N messages of the new Morse code. You have to figure out the number of messages which are compliant and ultimately sent forward. Output Specification: The number of messages compliant to the new decree. Example 1: input1: 1 input :{n} Output: 0 Explanation: The given string starts with a dot(.) and ends with a dash (-), but it fails the third criteria as there are 5 dots but only 4 dashes. Thus, 0 messages are compliant. Example 2: input1: 2 input2: {".,,,,,",,,"} Output: 2 Explanation: Both the given strings follow all 3 rules. Thus, both 2 messages are compliantStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started