Your question is Court Time Calculation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Hudl Sportscode records player substitutions as timestamped events during a match. Given the players on court at the start, substitution events, and the final match timestamp, calculate the total number of seconds each player was on the court.
Implement calculate_court_time(initial_players, events, end_time).
initial_players is a list of player ID strings on court at timestamp 0.events is a list of events represented as [timestamp, player_id, action], where action is either "in" or "out".end_time is the nonnegative integer timestamp when the match ends.initial_players or events to their total court time in seconds. Players who never enter must have a total of 0.Assume all timestamps are integers in [0, end_time], the input describes valid substitutions, and a player cannot be both on and off the court at the same time.
def calculate_court_time(initial_players, events, end_time):