I have 2 related lists of dictionaries, items
and bookings
. I need to determine which item has the least bookings.
The real example is in a database, but for the sake of the excercise, consider this data:
from datetime import datetime
item1 = {'foo1'}
item2 = {'foo2'}
items = [item1, item2]
booking1 = {'Start':datetime(2012,1,1), 'Item':'foo1'}
booking2 = {'Start':datetime(2012,1,2), 'Item':'foo1'}
booking3 = {'Start':datetime(2012,1,1), 'Item':'foo2'}
bookings = [booking1, booking2, booking3]
How can I efficiently determine which item has the fewest bookings? Any help would be greatly appreciated!