# Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
rentable_items = [
%w(x x x - - - x x x - - -), # item1
%w(- - - - - - - - - - - -), # item2
%w(x x x x x x x - - - - -), # item3
%w(x x x - - - - x x x x x) ]# item4
Ok,given that data-structure (which represents rent-slots in months of the items) where "x" stands for not-rentable and "-" stands for rentable, i have the following question.
When I have an incoming request for the period from April till June i want the result in the following priorized order:
items = rentable_items.ideal_utilization_for("2010/03/01", "2010/06/30")
items # [item1, item2, item4] #where item4 is the worst
The idea behind this is to fill the gaps of an item first and try to produce as few new gaps as possible.
I need no complete solution, but an advice which tools (library, gem, alogrithm) are availalbe for such a problem. Exemples would be very appreciated.
[Edit: Removed the second example, to focus on the real problem.]