Problem 8 (200pts): report_progress
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's user_id
, and a upload
function that is used to upload a progress report to the multiplayer server.
There will never be more words in typed
than in prompt
.
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 0.25
:
report_progress(["Hello", "ths", "is"], ["Hello", "this", "is", "wrong"], ...)
Your report_progress
function should do two things: upload a message to the multiplayer server and return the progress of the player with user_id
.
You can upload a message to the multiplayer server by calling the upload
function on a two-element dictionary containing the keys 'id'
and 'progress'
.
You should then return the player's progress, which is the ratio of words you computed.
Hint: See the dictionary below for an example of a potential input into the upload function. This dictionary represents a player with
user_id
1 andprogress
0.6.{'id': 1, 'progress': 0.6}
Before writing any code, unlock the tests to verify your understanding of the question:
$ python ok -q 08 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 08