A friend asks you to tune into a local numbers station, a radio station that is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A friend asks you to tune into a local numbers station, a radio station that is publishing a coded message. They say they've had a tip on how to decipher the messages the station is publishing, but want your help in writing a program that will do the deciphering. You start listening to the station and notice that in each voice sample the person reads out a number follow by letter or a hyphen-. The numbers don't seem to be in any particular order... You decide that you're going to help write the program, so your friend shares what the tip was • Every sample will contain a number which can be used to put the messages in order (sequence ID). • Every message only contains the letters a-z. A complete message is a continuous set of characters surrounded by two characters. • Sometimes a message is never completed (missing sequence IDs). . Once you've completed a full message, all messages completed later with a lower sequence ID are no longer useful and shouldn't be output (you should only output the latest message). • If two full messages are completed at the same time, then you should output only the message containing higher sequence IDs. A full broadcast can contain multiple complete messages and you will need to output each of them. Function Description You are to implement the function Process Sample that takes: • a sequence number for the sample, • the character for the sample. Whenever a full message is completed you should call the OnMessage Complete function with the completed message. Constraints • 0 <sequence id <264-1. . • number of messages >= 1 Input Format For each line, the first string is the sequence number associated with the sample, the second character is the character related to the sequence number. Sample Case 0 Sample Input 1- 2 h 3 e 41 51 60 7- 8 b Sample Output hello Explanation When the samples are placed in order according to their sequence IDs we get the following, -hello-b. There is one complete message here (between the characters) so it is output. Sample Case 1 Sample Input 1- 2 b 3 y 5- 6 h ********* 71 8- 4 e Sample Output hi Explanation When the samples are placed in order according to their sequence IDs we get the following, -bye-hi-. This broadcast contains two complete messages (bye and hi), but because the second complete message (hi) was completed before the first (bye), we only output the later message (hi). Sample Case 2 Sample Input 1- 2 h 3 e 41 Language Python 3 Autocomplete Ready 1 2 3 4 5 6 7 8 9 10 11 12 pass 13 if _name_ = "__main__":... Ⓒ Environment class Printer: def on message_complete (self, message): print(message) class Decoder: def_init_(self, printer): self.printer printer ⠀ def process_sample(self, sequence, character): # Complete code A friend asks you to tune into a local numbers station, a radio station that is publishing a coded message. They say they've had a tip on how to decipher the messages the station is publishing, but want your help in writing a program that will do the deciphering. You start listening to the station and notice that in each voice sample the person reads out a number follow by letter or a hyphen-. The numbers don't seem to be in any particular order... You decide that you're going to help write the program, so your friend shares what the tip was • Every sample will contain a number which can be used to put the messages in order (sequence ID). • Every message only contains the letters a-z. A complete message is a continuous set of characters surrounded by two characters. • Sometimes a message is never completed (missing sequence IDs). . Once you've completed a full message, all messages completed later with a lower sequence ID are no longer useful and shouldn't be output (you should only output the latest message). • If two full messages are completed at the same time, then you should output only the message containing higher sequence IDs. A full broadcast can contain multiple complete messages and you will need to output each of them. Function Description You are to implement the function Process Sample that takes: • a sequence number for the sample, • the character for the sample. Whenever a full message is completed you should call the OnMessage Complete function with the completed message. Constraints • 0 <sequence id <264-1. . • number of messages >= 1 Input Format For each line, the first string is the sequence number associated with the sample, the second character is the character related to the sequence number. Sample Case 0 Sample Input 1- 2 h 3 e 41 51 60 7- 8 b Sample Output hello Explanation When the samples are placed in order according to their sequence IDs we get the following, -hello-b. There is one complete message here (between the characters) so it is output. Sample Case 1 Sample Input 1- 2 b 3 y 5- 6 h ********* 71 8- 4 e Sample Output hi Explanation When the samples are placed in order according to their sequence IDs we get the following, -bye-hi-. This broadcast contains two complete messages (bye and hi), but because the second complete message (hi) was completed before the first (bye), we only output the later message (hi). Sample Case 2 Sample Input 1- 2 h 3 e 41 Language Python 3 Autocomplete Ready 1 2 3 4 5 6 7 8 9 10 11 12 pass 13 if _name_ = "__main__":... Ⓒ Environment class Printer: def on message_complete (self, message): print(message) class Decoder: def_init_(self, printer): self.printer printer ⠀ def process_sample(self, sequence, character): # Complete code
Expert Answer:
Answer rating: 100% (QA)
The Algorithm of the code Create a class named NumbersStation Define the main method within the class to serve as the entry point of the program Inside the main method Initialize two lists of strings ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
How do high-performance teams navigate the tension between task cohesion and social cohesion to achieve optimal levels of productivity, innovation, and interpersonal harmony ?
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Generate a matrix of random integer temperatures in Fahrenheit from 70 to 100 for 10 weeks (rows) and 7 days per week (columns). The result should look something like this. Assume the first column is...
-
By whom, and in what setting, was the relationship between electricity and magnetism discovered?
-
If all eigenvalues of a matrix are real, then the matrix is symmetric. (True/False)
-
Solicitous Bank offers your firm an 8 percent discount interest loan for up to \($3\) million, and in addition requires you to maintain a 6 percent compensating balance against the amount borrowed....
-
Comm Devices (CD) is a division of Worldwide Communications, Inc. CD produces pagers and other personal communication devices. These devices are sold to other Worldwide divisions, as well as to other...
-
Please Help! For entry #9 it says "Salaries Payable" is incorrect for both journals.. The following information about the weekly payroll was obtained from the records of Boltz Co.: Salaries: Deduct...
-
The TARDIS Corporation produces and sells a single product--Sonic Screwdrivers. TARDIS has the capacity to produce 100,000 Sonic Screwdrivers each year. If TARDIS produces at capacity, the per unit...
-
Answer the Following Querry: Solve ( dy dx2 n 2 ( +5%)=0 1
-
Johnny Cake Ltd. has 8 million shares of stock outstanding selling at $22 per share and an issue of $40 million in 10 percent annual coupon bonds with a maturity of 17 years, selling at 94.0 percent...
-
Marin Golf Inc. was formed on July 1, 2024, when Matt Magilke purchased the Old Master Golf Company. Old Master provides video golf instruction at kiosks in shopping malls. Magilke plans to integrate...
-
Annual dividends of Generic Electrical grew from $ 0 . 7 3 in 2 0 1 2 to $ 1 . 1 0 in 2 0 1 7 . What was the annual growth rate?
-
Be specific and Be concise while answering. Do not copy paste the material from any source Write in your on words. QUESTION NO. 1: i. "Differential Costs" are considered as relevant, where as "sunk...
-
What is the test statistic for testing the claim the proportion of people that like a product is different to 20%, if you have a sample where 2188 out of 10,000 customers like a product Note that...
-
You have analyzed the following four securities and have estimated each security's beta and what you expect each security to return next year.The expected return on the market portfolio is 13%, and...
-
Thalina Mineral Works is one of the worlds leading producers of cultured pearls. The companys condensed statement of cash flows for the years 20182020 follows. Required Comment on Thalina Mineral...
-
Distinguish between industrial relations and human resource management.
-
What would be the advantages and disadvantages of being represented by a union whose primary membership was in an industry or occupation different from yours?
-
Pinetree Lodge is a residence for elderly individuals who can no longer live on their own. The Residence Employees Union (REU) represents the 80 workers employed at Pinetree. On June 10, as required...
-
Explain why and how bond discount and bond premium affect (a) the balance sheet and (b) the income statement of the investor.
-
What are convertible bonds? What are the primary reasons for their use?
-
Under GAAP, when is it appropriate to use the (a) straight-line interest method and (b) effective interest method of amortization for bond discount or premium?
Study smarter with the SolutionInn App