This sounds like a very familiar problem. Before suggesting any algorithms, I will state some assumptions: At the time of this room assignment, the room statuses are staying in the constant state (i.e. all free rooms will remain free and all occupied rooms are not available for assignment and will remain that way) and the guest list is constant (we are asked to find the optimal arrangement for our guests given that no new guests will be signing up) Finally, a guest should be defined as a set of people (adults, children and infants) who make a single reservation. In other words, a family of two adults, one child and one infant is four people, but only one reservation.
With these disclamers in mind you want to do something like
- Take the first available room. For every reservation, find the reservation that has the correct number of people for that room.
- If no reservation is found that fits the room type completely, try finding a reservation with one fewer adults (least restrictive)
- If that doesn't work, then try finding a reservation with one fewer children (next most restrictive)
- If that doesn't work, then try finding a reservation with one fewer infants (lease restrictive)
- If that doesn't work, then try finding a reservation with one fewer adults and one fewer children then one fewer adults and one fewer infants and one fewer children and one fewer infants
- etc ...
This would require many passes through the guest list, but for a usual hotel, we are only talking about reservations numbering in low hundreds at most, so algorithm execution should not be that great of a concern. Hope this helps.