Steven Bethard wrote:
I have a list of dictionaries. Each dictionary holds counts of various 'words', e.g.:

py> countdicts = [
...     dict(a=9, b=9, c=9),
...     dict(a=8, b=7),
...     dict(a=4, b=5, c=12)]

I need to select dicts with the constraint that the number of each 'word' totalled over all selected dicts doesn't exceed a given MAX_VALUE. Right now, I do this by:

Not that you can't still improve performance of course, but this is an NP-complete problem if you didn't know, so don't bang your head too hard...


--
Brian Beck
Adventurer of the First Order
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to