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

  • Home
  • SEARCH
  • 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 8203281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:29:51+00:00 2026-06-07T07:29:51+00:00

I’m trying to do the following, and can’t figure out how exactly do It

  • 0

I’m trying to do the following, and can’t figure out how exactly do It without crashing or infinite looping:

I have to create a queue in which I have to distribute different tasks a different number of times each, alternatively with this kind of info:

  • Task X: [NextOne,LastOne]

    • Task 1: [30,32]
    • Task 2: [76,81]
    • Task 3: [2,2]
    • Task 4: [5,8]

Meaning that “Task X” will be made “LastOne – NextOne” times, and if both are equal, it won’t be enqueued, and they enter the queue in X order.
With this example, the queue should look like:

FIRST
Task1[30]
Task2[76]
Task4[5]
Task1[31]
Task2[77]
Task4[6]
Task1[32]
Task2[78]
Task4[7]
Task2[79]
Task4[8]
Task2[80]
Task2[81]
LAST

It’s not a language issue, it’s more of an algorithm issue I have here. Using PHP I’ve made the following:

$tasks = array(
'Task1' => array(30,32),
'Task2' => array(76,81),
'Task3' => array(2,2),
'Task4' => array(5,8)
);


$aux = array();
$i=0;
foreach($tasks as $s=>$n) {
    $aux[$i]['task'] = $s;
    $aux[$i]['times'] = $n[1]-$n[0];
    $aux[$i]['first'] = $n[0];
    $i++;
}

But as you imagine this actually does nothing, just change the shape of the information. I’m really stuck here I don’t know why, this actually shouldn’t be hard to figure out. I’d appreciate any help.

  • 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-07T07:29:52+00:00Added an answer on June 7, 2026 at 7:29 am

    In python (I may be misinterpreting your “it’s not a language issue” comment – forgive me):

    tasks = [
        ("Task1", 30, 32),
        ("Task2", 76, 81),
        ("Task3", 2, 2),
        ("Task4", 5, 8) ]
    
    while not tasks == []:
        # Pop first task off the current list
        (n, s, e) = tasks[0]
        tasks = tasks[1:]
    
        print n, s
        if s != e:
            tasks.append( (n, s+1, e) )
    

    Sorry it’s not in php – it’s not my forte, but perhaps this’ll help? Output:

    Task1 30
    Task2 76
    Task3 2
    Task4 5
    Task1 31
    Task2 77
    Task4 6
    Task1 32
    Task2 78
    Task4 7
    Task2 79
    Task4 8
    Task2 80
    Task2 81
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put

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.