Logic question for a program I'm designing I'm developing an application in ASP.NET with C# and i'm trying to figure out the best way to implement a logic statement that will stop the system from allowing another reservation to be taken if the trailer for canoes and kayaks is full. The issue is the trailer will hold canoes and kayaks, but there's a lot of different combinations.
There are 5 "rows" on the trailer that count upwards vertically, and 2 "columns" that dissect the 5 rows in the middle. I will draw you a diagram to show you what it looks like, and what boats can go where. "C" will stand for Canoe and "K" will stand for Kayak. The trailer looks like this:
C only|C only  }
______|______  }  BOAT TRAILER
 1C\2K|1C\2K   }
______|______  }     
 1C\2K|1C\2K   } 
______|______  }
 1C\2K|1C\2K   }
______|______  }
C only| C only }
______|______  }

So my question is, what's the best option as far as logic is concerned to not take any more "reservations" when the trailer is full? This application will be a .aspx form that will do an insert command to SQL server taking customer information. 
[I posted this on the stack overflow site and someone suggested I post this here because one of you might enjoy this problem!]
Thanks!
 A: It looks like you have ten bays, six of which can take either one canoe or two kayaks and four which can take only one canoe, so count bays.   


kayak bays=kayaks/2 (round up)
    canoe bays=canoes
    bays=kayak bays+canoe bays
    if (kayak bays > 6 or bays > 10) fail  


When somebody tries to make a reservation, total up the existing reservations with the new one and check for fail.
A: The trouble here is to define what an optimal solution is. I think we can make the following two assumptions:


*

*Since you don't control what reservations you'll get or in what order, we may as well think of the reservations as some predetermined sequence of canoe or kayak reservations which we don't know ahead of time.

*Once you accept a reservation and put their boat on the trailer, you never remove it in order to make room for a reservation that you receive later: that is, you never cancel reservations.

*When you receive a reservation, if it is at all possible to put their boat on the trailer along with the boats already meant to be on there, you put it on. You do not try to strategize based on what reservations might be made in future: the process is first-come-first-served.


So an optimal logic is one such that, no matter what the sequence of reservations is, obeys rules 2 and 3.
This logic seems like it should fit the bill:
Receive canoe reservation
    If there's a canoe-only slot open
        Use that
    Else
        If there's any other slot open
             Use that
        Else
             No room for canoes
Receive kayak reservation
    If there's a slot with exactly one kayak in it
        Use that
    Else
        If there's any kayak-capable slot open
             Use that
        Else
             No room for kayaks

You might be able to prove that this satisfies the above requirements by induction, but it seems obvious to me that you can't do better than this algorithm.
