Problem 9 (100pts): time_per_word
Implement time_per_word
, which takes in times_per_player
, a list of lists for each player with timestamps indicating when each player finished typing each word. It also takes in a list words
. It returns a game
with the given information.
A game
is a data abstraction that has a list of words
and times
. The times
are stored as a list of lists of how long it took each player to type each word. times[i][j]
indicates how long it took player i
to type word j
.
For example, if times_per_player = [[1, 3, 5], [2, 5, 6]]
, the corresponding time
attribute of the game
would be [[2, 2], [3, 1]]
. Timestamps are cumulative and always increasing, while the values in time
are differences between consecutive timestamps.
Be sure to use the game
constructor when returning a game
, rather than assuming a particular data format.
# Test your implementation
python ok -q 09