Comment

Comment by sidpatil

Isn't this a knapsack problem [1]? It looks like it can be represented as a linear program:

Maximize sum(x)

subject to constraint:

P•x = 43.94

where P is a vector of prices of each toy, and x is a vector of quantities purchased of each toy.

Then one can either plug this into an LP solver, or can solve it by hand using simplex or other algorithm.

[1] https://en.m.wikipedia.org/wiki/Knapsack_problem

parent sidpatil 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton