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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:13:42+00:00 2026-05-23T06:13:42+00:00

So recently I was given a problem, which I have been mulling over and

  • 0

So recently I was given a problem, which I have been mulling over and am still unable to solve; I was wondering if anyone here could point me in the right direction by providing me with the psuedo code (or at least a rough outline of the pseudo code) for this problem. PS I’ll be building in PHP if that makes a difference…

Specs

There are ~50 people (for this example I’ll just call them a,b,c… ) and the user is going to group them into groups of three (people in the groups may overlap), and in the end there will be 50-100 groups (ie {a,b,c}; {d,e,f}; {a,d,f}; {b,c,l}…). *

So far it is easy, it is a matter of building an html form and processing it into a multidimensional array


There are ~15 time slots during the day (eg 9:00AM, 9:20AM, 9:40AM…). Each of these groups needs to meet once during the day. And during one time slot the person cannot be double booked (ie ‘a’ cannot be in 2 different groups at 9:40AM).

It gets tricky here, but not impossible, my best guess at how to do this would be to brute force it (pick out sets of groups that have no overlap (eg {a,b,c}; {l,f,g}; {q,n,d}…) and then just put each into a time slot


Finally, the schedule which I output needs to be ‘optimized’, by that I mean that ‘a’ should have minimal time between meetings (so if his first meeting is at 9:20AM, his second meeting shouldn’t be at 2:00PM).

Here’s where I am lost, my only guess would be to build many, many schedules and then rank them based on the average waiting time a person has from one meeting to the next


However My ‘solutions’ (I hesitate to call them that) require too much brute force and would take too long to create. Are there simpler, more elegant solutions?

  • 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-05-23T06:13:43+00:00Added an answer on May 23, 2026 at 6:13 am

    These are the table laid out, modified for your scenerio

    +----User_Details------+  //You may or may not need this
    | UID | Particulars... |
    +----------------------+
    
    +----User_Timeslots---------+  //Time slots per collumn
    | UID | SlotNumber(bool)... |  //true/false if the user is avaliable
    +---------------------------+  //SlotNumber is replaced by s1, s2, etc
    
    +----User_Arrangements--------+  //Time slots per collumn
    | UID | SlotNumber(string)... |  //Group session string
    +-----------------------------+
    

    Note: That the string in the Arrangement table, was in the following format : JSON

    ‘[12,15,32]’ //From SMALLEST to BIGGEST!

    So what happens in the arrangement table, was that a script [Or an EXCEL column formula] would go through each slot per session, and randomly create a possible session. Checking all previous sessions for conflicts.

    /**
    * Randomise a session, in which data is not yet set
    **/
    function randomizeSession( sesionID ) {
        for( var id = [lowest UID], id < [highest UID], id++ ) {
            if( id exists ) {
                randomizeSingleSession( id, sessionID );
            } //else skips
        }
    }
    
    /**
    * Randomizes a single user in a session, without conflicts in previous sessions
    **/
    function randomizeSingleSession( id, sessionID ) {
    
        convert sessionID to its collumns name =)
        get the collumns name of all ther previous session
    
        if( there is data, false, or JSON ) {
            Does nothing (Already has data)
        }
    
        if( ID is avaliable in time slot table (for this session) ) {
            Get all IDs who are avaliable, and contains no data this session
            Get all the UID previous session
            while( first time || not yet resolved ) {
                Randomly chose 2
                if( there was conflict in UID previous session ) {
                    try again (while) : not yet resolved
                } else {
                    resolved
                }
            }
    
            Registers all 3 users as a group in the session
    
        } else {
            Set session result to false (no attendance)
        }
    }
    

    You will realize the main part of the assignment of groups is via randomization. However, as the amount of sessions increases. There will be more and more data to check against for conflicts. Resulting to a much slower performance. However large being, ridiculously large, to an almost perfect permutation/combination formulation.

    EDIT:

    This setup will also help ensure, that as long as the user is available, they will be in a group. Though you may have pockets of users, having no user group (a small number). These are usually remedied by recalculating (for small session numbers). Or just manually group them together, even if it is a repeat. (having a few here and there does not hurt). Or alternatively in your case, along with the remainders, join several groups of 3’s to form groups of 4. =)

    And if this can work for EXCEL with about 100+ ppl, and about 10 sessions. I do not see how this would not work in SQL + PHP. Just that the calculations may actually take some considerable time both ways.

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

Sidebar

Related Questions

Have recently been given a project to complete which uses XML quite extensively.Am looking
I have recently been given a task to add the ability to interact with
Recently in a job interview, I was given the following problem. Say I have
recently I was given the task to discover a C# solution I have never
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
I use a cluster of about 30 machines that have all recently been reconfigured
Recently I have been studying recursion; how to write it, analyze it, etc. I
recently I have been trying my hand at coding a game in C#. I'm
I have recently put together a JWS application which gets it's argument from a
I have been recently learning some OOP PHP and seem to have run into

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.