Home /
Expert Answers /
Computer Science /
how-to-attempt-royal-morse-code-the-royal-british-kingdom-has-enforced-a-new-decree-in-the-society-pa329
(Solved): How to Attempt? Royal Morse Code The Royal British Kingdom has enforced a new decree in the society ...
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 \( \mathrm{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 input2: \( \left\{x^{*} \ldots \ldots *^{n}\right) \) 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: \( \left\{", \ldots, \ldots, n^{\prime \prime}, \ldots=\cdots,-"\right\} \) Output: 2 Explanation: Both the given strings follow all 3 rules. Thus, both 2 messages are compliant.