Question: 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

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 compliant

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!