Junior — Senior
Merging two step functions while preserving all measurement points
livecode
Task condition
Given are two step graphs representing the values of some quantity over time. Each graph is defined by a sorted array of pairs {coordinate, value}, where the coordinate is the point in time when a new step begins, and the value is maintained until the next coordinate. Before the first coordinate, the value is considered zero. The task is to construct a combined graph that contains all measurements from both original graphs, with the value at each point being the sum of the corresponding values from the first two graphs.
sum_series(first={{1, 2}, {5, 1}}, second={{2, 4}, {3, 6}, {9, 7}}) -> {{1, 2}, {2, 6}, {3, 8}, {5, 7}, {9, 8}}