Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
> I think this is known as the Subset Sum Problem.

Well ... almost.

The Subset Sum Problem asks if there is one solution.

But the OP asks to "list all possible combination of numbers"

Algorithm wise that's a huge difference, because one can often optimize searching for a single solution, while happily ignoring the rest.

And that's also why I'm hesitant solving this, you can easily show that the solution space of all possible combinations will explode quickly, in a way that already the time needed to print them out will take an eternity.

I.O.W. such problems don't make much sense, unless you are singling out a single (or a few) solution which are optimal regarding a second value-function.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

)The Knapsack Problem will also demand to optimize a second "value" function and only require the "weight" to be less or equal the "target". It's a generalization of Subset Sum b/c if you choose the weight as value, the equal case - if it exists - will be maximal.


In reply to Re^2: Find combination of numbers whose sum equals X by LanX
in thread Find combination of numbers whose sum equals X by harangzsolt33

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (4)
    As of 2021-01-23 21:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?