subject

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. Timestamps are cumulative and always increasing, while the values in time are differences between consecutive timestamps for each player. def time_per_word(times_per_player, words):
"""Given timing data, return a game data abstraction, whichcontains a list
of words and the amount of time each player took to type eachword.
Arguments:
times_per_player: A list of lists of timestamps including thetime
the player started typing, followed by the time
the player finished typing each word.
words: a list of words, in the order they are typed.
"""
And here is the game definition
def game(words, times):
"""A data abstraction containing all words typed and theirtimes."""
assert all([type(w) == str for w in words]), 'words should be alist of strings'
assert all([type(t) == list for t in times]), 'times should be alist of lists'
assert all([isinstance(i, (int, float)) for t in times for i int]), 'times lists should contain numbers'
assert all([len(t) == len(words) for t in times]), 'There should beone word per time.'
return [words, times]
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.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:30, quesorules7101
Larry sent an email to andy. andy didn't open larry's email but still understood what the message was. how did andy determine the message without opening the email?
Answers: 1
image
Computers and Technology, 23.06.2019 06:40, sardarp1irc5
What are the three uses of a screw?
Answers: 2
image
Computers and Technology, 23.06.2019 08:00, Buddy01
Match the items with their respective descriptions.
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, mprjug6
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
You know the right answer?
Implement time_per_word, which takes in times_per_player, a list of lists for each player with times...

Questions in other subjects:

Konu
Chemistry, 12.07.2019 17:30
Konu
Mathematics, 12.07.2019 17:30