$\begingroup$

So this is my problem:

I have a calendar with time slots denoting availabilities and bookings of various lengths. What I want is to be able to determine the best position for new incoming bookings within the existing availabilities in such a manner that I maximise coverage and leave as little gaps as possible. The tricky part here is that I have to offer multiple positions (various dates and times) for the new booking that should each waste as little space as possible while not knowing what future bookings will look like in either length or number.

I have a feeling this may be related to some know mathematical problem. Does it sound familiar? If not - what approach could I follow to break down this problem and solve it?