Question

problem 8 &amp; 9

Image transcriptions

def report_progress (typed, prompt, id, send) : &quot;&quot;&quot;Send a report of your id and progress so far to the multiplayer server . &quot;un # BEGIN PROBLEM 8 &quot; *** YOUR CODE HERE *&lt;&gt;*&gt;* &quot;! # END PROBLEM 8 def fastest_words_report (word_times ) : &quot;&quot; &quot;Return a text description of the fastest words typed by each player . &quot; &quot; &quot; fastest = fastest_words (word_times) report = ' ' for i in range (len(fastest) ) : words = ' , '. join(fastest[i]) report += 'Player {} typed these fastest: {}\n' . format(i + 1, words) return report def fastest_words (word_times, margin=le-5) : &quot;&quot;&quot;A list of which words each player typed fastest.&quot;ull n_players = len(word_times) n_words = len(word_times[0]) - 1 assert all(len (times ) == n_words + 1 for times in word_times) assert margin &gt; 0 # BEGIN PROBLEM 9 &quot; ** YOUR CODE HERE *&lt;&gt;*&gt;* &quot; # END PROBLEM 9

Problem 8 (2 pt) Implement report_progress , which is called every time the user finishes typing a word. It takes a list of the words typed , a list of the words in the prompt , the user id, and a send function that is used to send a progress report to the multiplayer server. Your progress is a ratio of the words in the prompt that you have typed correctly, up to the first incorrect word, divided by the number of prompt words. For example, this example has a progress of 6.25: report_progress([&quot;Hello&quot;, &quot;ths&quot;, &quot;15&quot;], [&quot;Hello&quot;, &quot;this&quot;, 15&quot;, &quot;wrong&quot;], ...) Your report_progress function should return this number. Before that, it should end a message to the multiplayer server that is a two-element dictionary containing the keys 'id' and 'progress' . The id is passed into report_progress from the GUI. The progress is the fraction you compute. Call send on this dictionary to send it to the multiplayer server.

Problem 9 (3 pt) Implement fastest_words , which returns which words each player typed fastest. This function is called once both players have finished typing. It takes word_times and a positive margin . The word_times argument is a list of lists of word_time values, one list for each player, and within each list n+1 elements for the total elapsed time in the race after that player has finished typing each of the n words, as well as an entry at the beginning with zero elapsed time for the special word 'START' . It returns a list of lists of words, one list for each player, and within each list the words they typed the fastest. Definition: A player typed a word the fastest if the difference between their elapsed time for that word and the previous word is within margin of the smallest difference for any player. Therefore, if two players type a word within margin of each other, that word will appear in both of their lists. Be sure to use the word and e1apsed_time accessor functions for the word_time data abstraction, rather than assuming a particular data format.

def report_progress (typed, prompt, id, send) : &quot;&quot;&quot;Send a report of your id and progress so far to the multiplayer server . &quot;un #...

372,107 students got unstuck by Course
Hero in the last week