Subset sum problem: Difference between revisions

m
added whitespace and bullet points to the task's preamble, added a (bold) section (For example).
m (→‎{{header|REXX}}: elided STYLE for the PRE HTML tag.)
m (added whitespace and bullet points to the task's preamble, added a (bold) section (For example).)
Line 1:
{{draft task|Discrete math}}
 
 
;Task:
Implement a function/procedure/method/subroutine that takes a set/array/list/stream/table/collection of words with integer weights, and identifies a non-empty subset of them whose weights sum to zero (cf. the Dropbox [http://www.dropbox.com/jobs/challenges Diet] candidate screening exercise and the [[wp:Subset sum problem|Subset sum problem]] Wikipedia article).
 
:for example:
This set of weighted words, one solution would be the set of words:
:::*   {elysee,   efferent,   deploy,   departure,   centipede,   bonnet,   balm,   archbishop}
because their respective weights of:
:::*   -326,   54,   44,   952,   -658,   452,   397,   and   -915
sum to zero.
 
:::::: {| style="text-align: left; width: 40%;" border="5" cellpadding="2" cellspacing="2"
For example, for this set of weighted words, one solution would be the set of words {elysee, efferent, deploy, departure, centipede, bonnet, balm, archbishop}, because
their respective weights of -326, 54, 44, 952, -658, 452, 397, and -915 sum to zero.
:::: {| style="text-align: left; width: 40%;" border="5" cellpadding="2" cellspacing="2"
|+             Table of weighted words
|- style="background-color: rgb(255, 204, 255);"