Steven Bethard wrote:
> Anyway, do you know what name this problem is usually discussed under?
If I knew what to google for, I could probably find at least a few
simple heuristics to try...
I think the closest thing would be the 'knapsack problem' or the 'subset
sum problem.'
http://en.wikipedi
Brian Beck wrote:
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
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 ov
John Machin wrote:
Steven Bethard wrote:
I have a list of dictionaries. Each dictionary holds counts of
various 'words'...
...
Basically, I use a greedy approach -- adding a dict each time if I
can.
...
This leads to some suboptimal solutions given that, while the total
counts must not exceed MAX
Steven Bethard wrote:
> I have a list of dictionaries. Each dictionary holds counts of
various
> 'words', e.g.:
> Basically, I use a greedy approach -- adding a dict each time if I
can.
> This leads to some suboptimal solutions given that, while the total
> counts must not exceed MAX_VALUE, I
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