Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Sum Finder
We are given the set of numbers Our goal is to determine if can be obtained as a sum of a subset of . While this can be determined by a brute-force attack, the goal is to use a dynamic programming approach.
We enumerate the elements of as Let be a 5-by-18 binary matrix such that if some subset of sums up to otherwise
It is clear that for all and for and
From the definition of if follows that, for :
if
if and
if
The last equality is determined by the following idea. If then can be formed as a sum of a subset of that does not include If then can be formed as a sum of a subset of that does include If then there is no way to form as a sum of a subset of
Following the rules above, we give a complete characterization of as follows:
Since , we see that can be formed as a sum of a subset of . Futhermore, the chart above can used to see that .