I have seconds input ordered data from smallest to largest for both times.
start_time[s] = [10, 20, 30, 40, 50, 61, 79, 80]
end_time[s] = [8, 9, 15, 31, 41, 60]
The lists are not the same sizes as they are generated log file timestamp data
I want to get output for the positive difference between end_time and the minimum of the start_time
The code I have is as follows:
for item1 in end_time:
for item2 in start_time:
if (item1 > item2):
new_item = item1 - item2
new_list.append(new_item)
[5, 21, 11, 1, 31, 21, 11, 1, 50, 40, 30, 20, 10]
The ideal output will be generated as follows:
[5, 11, 11, 20]
5…this is by taking the end_time of 15 – the start_time of 10, why? Its the first end_time > start_time (8,9 are also end_times less than 10)
11…this is by taking the next end_time of 31 (i don’t want to use 15 as i will be double counting) and then subract the next start_time of 20 to give 11.
11…this is by taking the following end_time of 41 and subtracting the start_time of 30 to give 11.
20…this will be the last entry, it takes the 60 from the end_time and uses 40 from the start_time to give a difference of 20.
I’m assuming that both lists are in order, which is what your sample data shows.
Note that I have no sanity checking (e.g. the same end time could be used over and over).