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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:32:15+00:00 2026-06-18T20:32:15+00:00

Is there a generic algorithm I can employ to solve the following problem: Given:

  • 0

Is there a generic algorithm I can employ to solve the following problem:

Given:

Background: A month, which has 0 to 1000 events (any number really). Each event has a start and end dates. Events take place in rooms, one at a time (no overlaps, however consequent events are allowed to share end and start dates with each other). The number of rooms is unlimited.

The challenge: Allocate rooms for the events such that the number of rooms required to host monthly events is kept to a minimum.

While the complete solution is highly appreciated I’m looking for any directions, smart ideas.


class Event: 
- int Id;
- DateTime StartDate; 
- DateTime EndDate

class Allocation:
- int EventId
- int RoomId

so I’m looking for:

// roomIds is Enumerable.Range(1, int.MaxValue)
IEnumerable<Allocation> GetAllocations(IEnumerable<Event> events, IEnumerable<int> roomIds, int year, int month)
{
  ...
}
  • 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-18T20:32:16+00:00Added an answer on June 18, 2026 at 8:32 pm

    Split every event into two timepoints labeled ‘start’ and ‘end’ (keeping the back pointer to the original event), sort all the points on time – break ties so that ‘end’s come before ‘start’s with the same time.

    Now go over the points (in the order defined above), allocating first free number on each ‘start’ and freeing the associated number on each ‘end’.

    Example:

    Events: 9AM-5PM, 9AM-2PM, 5PM-6PM, 3PM-6PM

    Sorted table of timepoints:

    (9AM start event1), (9AM start event2), (2PM end event 2), (3PM start event4), (5PM end event1), (5PM start event3), (6PM end event3), (6PM end event4)

    Processing:

    (9AM start event1) - assign room 1 to event1
    (9AM start event2) - assign room 2 to event2
    (2PM end event2) - free room 2
    (3PM start event4) - assign room 2 to event4
    (5PM end event1) - free room 1
    (5PM start event3) - assign room 1 to event3
    (6PM end event3) - free room 1
    (6PM end event4) - free room 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a genetic algorithm. There are two objective and each one has
In the .net framework, there's a generic IEnumerable<T> interface which inherits from the not-generic
There doesn't appear to be a generic implementation of OrderedDictionary (which is in the
Is there a limit on the amount of generic parameters you can have on
Is there any generic alternative / implementation for MemoryCache? I know that a MemoryCache
Is there a generic way of determining all attributes (and their values) from an
Is there a generic TimeZoneInfo for Central Europe that takes into consideration both CET
In ASP.NET MVC there are generic master views ( ViewMaserPage<T> ). But what is
There is any way to set the generic type (T) of class in the
Is there any way to store the generic parameter type passed in at construction

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.