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 57345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:40:36+00:00 2026-05-10T17:40:36+00:00

I am looking for an algorithm to calculate the next set of operations in

  • 0

I am looking for an algorithm to calculate the next set of operations in a sequence. Here is the simple definition of the sequence.

  1. Task 1A will be done every 500 hours
  2. Task 2A will be done every 1000 hours
  3. Task 3A will be done every 1500 hours

So at t=500, do 1A. At t=1000, do both 1A and 2A, at t=1500 do 1A and 3A, but not 2A as 1500 is not a multiple of 1000. You get the idea.

It would be quite easy if I had the actual time, but I don’t. What I have is the history of tasks (eg last time a [1A+2A] was done).

Knowing last time (eg [1A+2A]) is not enough to decide:

  • [1A+2A] could be at t=1000: next is [1A+3A] at t=1500
  • [1A+2A] could be at t=5000: next is [1A] at t=5500

Is there an algorithm for this? It looks like a familiar problem (some sort of sieve?) but I can’t seem to find a solution.

Also it must ‘scale’ as I actually have more than 3 tasks.

  • 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. 2026-05-10T17:40:36+00:00Added an answer on May 10, 2026 at 5:40 pm

    Bill the Lizard is right. Here is how to determine the task intervals from the history (in Python):

    history = [list of tuples like (timestamp, (A, B, ...)), ordered by timestamp] lastTaskTime = {} taskIntervals = {}  for timestamp, tasks in history:     for task in tasks:         if task not in lastTaskTime:             lastTaskTime[task] = timestamp         else:             lastTimestamp = lastTaskTime[task]             interval = abs(timestamp - lastTimestamp)             if task not in taskIntervals or interval < taskIntervals[task]:                 taskIntervals[task] = interval  # Found a shorter interval              # Always remember the last timestamp             lastTaskTime[task] = timestamp  # taskIntervals contains the shortest time intervals of each tasks executed at least twice in the past # lastTaskTime contains the last time each task was executed 

    To get the set of tasks, which will be executed next:

    nextTime = None nextTasks = []  for task in lastTaskTime:     lastTime = lastTaskTime[task]     interval = taskIntervals[task]      if not nextTime or lastTime + interval < nextTime:         nextTime = lastTime + interval         nextTasks = [task]     elif lastTime + interval == nextTime:         nextTasks.append(task)  # nextTime contains the time when the next set of tasks will be executed # nextTasks contains the set of tasks to be executed 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I was looking around the internet and couldn't find a perfect algorithm for this
I find myself needing to generate a checksum for a string of data, for
How to, in C# round any value to 10 interval? For example, if I
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.