Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Find combination of numbers whose sum equals X

by QM (Parson)
on Nov 20, 2020 at 10:20 UTC ( [id://11123880]=note: print w/replies, xml ) Need Help??


in reply to Find combination of numbers whose sum equals X

I think this is known as the Subset Sum Problem.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: Find combination of numbers whose sum equals X
by LanX (Saint) on Nov 21, 2020 at 22:50 UTC
    > 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123880]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-23 19:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found