### Comment on

 Need Help??

I have an array having some interger elements. I have to split into 2 subsets. Need to verify that sum of these 2 subsets are equal or not. Subset size is not matter, it can be element count of 3,2 or 1,4 or any but should be in 2 part. For example...

Ex 1: @a1 = qw(1, 3, 8, 4); This array can be divided into to subsets (1,3,4)=8 and (8)=8, so these two have equal sum.

Ex 2: @a1 = qw(1, 6, 2); This cant be divided into two subsets of equal sum.Because (1,6)!=2 or any combination of a subset is not matching to another subset.

I tried below code but it is working for one set of iteration, actually it should check all possible set of iteration to find possiblities.

```my @array= qw(1 3 5 7);
my @array= qw(1 3 5 7);
&test(\@array);

sub test
{
my (\$s1,\$s2);
my @a=@{\$_[0]};
for (my \$i=0;\$i<=\$#a ;\$i++) {
(\$s1,\$s2)=0;
for (my \$j=0;\$j<=\$#a ;\$j++) {
if (\$i == \$j) {
\$s1=\$s1+ \$a[\$j];
}
else{
\$s2+=\$a[\$j];
}
}

}
print "\n";
}

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.
• 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [LanX]: whats the best way to restrict a MySQL Text Column to alphanums + underscore ? [LanX]: CHARACTER SET? [chacham]: ought to be a check constraint.

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-03-30 14:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (360 votes). Check out past polls.