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...
-
The temperature dependence of the vapour pressure of solid sulfur dioxide can be approximately represented by the relation log (p/Torr) = 10.5916 - 1871.2/ (T/K) and that of liquid sulfur dioxide by...
-
The data in the table below were obtained during a colorimetric determination of glucose in blood serum. Glucose concentration, mM Absorbance, A...
-
Many large cities have recently enacted living wage ordinances that require paying a minimum wage that is higher than the state or federal minimum wage. Moreover, sometimes living wage ordinances...
-
The Ploughman family owns and operates a 640-acre farm that has been in the family for several generations. The Ploughmans always have had to work hard to make a decent living from the farm and have...
-
The position of a particle moving along the x axis is given in centimeters by x = 9.36 + 1.34 t 3 , where t is in seconds. Calculate (a) the average velocity during the time interval t = 2.00 s to t...
-
Tamar Company manufactures a single product in two departments: Forming and Assembly. Information for the Forming process for May follows. Beginning work in process inventory Units started this...
-
Two spheres have the same positive charge Q and the same mass m. They hang vertically from the ceiling, each attached at the end of a string of length L. Because of the repulsive electric force...
-
What are the implications of neural stem cell plasticity and neurogenesis in the adult brain for regenerative medicine and therapeutic interventions targeting neurodegenerative diseases and traumatic...
-
Waterway WaterWorks manufactures snorkel gear. During the past month, Washington purchased 2,800 pounds of plastic to use in its dive masks, at a cost of $5,600. The standard price for the plastic is...
-
What are the important units of microprocessor/microcontroller? Briefly describe each. What are the different softwares used in embedded system? Briefly describe each. What are the steps in...
-
Harrison Clothiers' stock currently sells for $24 a share. The stock just paid a dividend of $1.20 a share. The dividend is expected to grow at a constant rate of 12 percent a year. What stock price...
-
Please calculate the Bonus Amount for each row according to the Commission Table on the right side. Once with IF statements
-
Choose any mortgage with points from any site (please provide a url or copy the ad). What is the interest rate on that mortgage? What is the APR? Why are they different? Assume that you pre-pay the...
-
Rewrite Programming Exercise 7.5 using streams. Display the numbers in increasing order. Data from Programming Exercise 7.5 Write a program that reads in 10 numbers and displays the number of...
-
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...
-
At the instant shown in Figure 32. 40 , the potential difference across the capacitor is half its maximum value and the charge on the plates is increasing. Draw the direction of the current and...
-
Construct a phasor diagram representing the current and potential difference in Figure 32. 10 at \(t=T / 4, T / 2\), and \(3 T / 4\). Data from Figure 32.10 Ve maximum, current zero Ve minimum,...
-
The research laboratory you work in is less than a block away from the transmitting antenna of a radio station that broadcasts at \(1100 \mathrm{kHz}\). You notice that every piece of equipment in...
Study smarter with the SolutionInn App