Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:05:31+00:00 2026-06-08T00:05:31+00:00

I have seconds input ordered data from smallest to largest for both times. start_time[s]

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:05:33+00:00Added an answer on June 8, 2026 at 12:05 am

    I’m assuming that both lists are in order, which is what your sample data shows.

    timeDeltas = []
    idxStart = 0
    idxEnd =  len(end_time)
    for start in start_time:
        for i in range(idxStart, idxEnd)
            delta = 0
            end = end_time[i]
            if end > start:
                delta = end - start
                idxStart = i
            else:
                timeDeltas.append(delta)
                break
    

    Note that I have no sanity checking (e.g. the same end time could be used over and over).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to extract hours, seconds and minutes from an input text
I'm trying to have Joda print 0 seconds if the input time is zero,
I have the input 15:20:30 I want to convert to seconds.
I have a method void DoWork(object input) that takes roughly 5 seconds to complete.
The input string is '20100908041312' the format is year,month,day,Hours,minutes,seconds,time zone and I have ben
I have an application that scans an input directory every five seconds and when
Situation: I have a function that dumps input data into an HTML block element,
I have a form where I have to have the input elements ordered specifically.
I have a form with an input text field which imports data every couple
I have a text input and a textarea and I'm passing the value from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.