Subset sum...

From: B.r.K.o.N.j.A. (thebrkonja_at_inet.hr)
Date: 12/17/03


Date: Wed, 17 Dec 2003 18:25:12 +0100

I have to write a program (predicate) sum_subset(List, SubSet, Sum) which
returns true if sum of Subset equals Sum, for example

sum_subset([1,2,5,3,2], Subset, 5).
Subset=[1,2,2]
Subset=[2,3]

and so on,

Please help, I'm kindda stuck. Please point me in the right direction (or
tell me the proper english term for this so I can search the web since
English is not my native language)

Thanks

Vedran



Relevant Pages

  • Re: Subset sum...
    ... >returns true if sum of Subset equals Sum, ... >tell me the proper english term for this so I can search the web since ... This predicate succeeds if SubSet is a subset of List AND SubSet sums to ...
    (comp.lang.prolog)
  • Re: Subset sum...
    ... > tell me the proper english term for this so I can search the web since ... and test if the sum is 5. ... If not, backtrack. ... I'll even give you the toplevel predicate for free: ...
    (comp.lang.prolog)
  • Re: Subset sum...
    ... Thanks, I've written the sum predicate, and it works, but I have trouble ... > This predicate succeeds if SubSet is a subset of List AND SubSet sums to ... > Nick Wedd nick@maproom.co.uk ...
    (comp.lang.prolog)
  • Re: trouble making a simple calculator with prolog
    ... you should make sure that there is a predicate defined for it: ... The goal sum is X+Y cannot succeed - although it does not raise any message ... I have now 98 good deeds to do before I can be inconsistent again. ...
    (comp.lang.prolog)
  • Re: Little problem please help
    ... Magellan wrote: ... >> sum(S, Sum), ... >>You will need to write the predicate 'sublist', which succeeds if its ... > I think that I did something wrong in predicate sublist, ...
    (comp.lang.prolog)