- or download this
#!/usr/bin/env perl -l
...
") and (", join(", " => sort { $a <=> $b } @a2), ")";
print "\tSubset sum = $half";
}
- or download this
$ pm_split_equal_sums.pl
Checking: (1, 3, 8, 4)
...
Checking: (5, 5, 4, 6, 2, 8, 1, 9)
Subsets: (1, 2, 8, 9) and (4, 5, 5, 6)
Subset sum = 20
- or download this
#!/usr/bin/env perl -l
...
return 0
}
}
- or download this
$ prove pm_split_equal_sums.pl
pm_split_equal_sums.pl .. ok
All tests successful.
Files=1, Tests=19, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.02 cusr
+ 0.00 csys = 0.06 CPU)
Result: PASS
- or download this
$ pm_split_equal_sums.pl
1..19
...
Checking: (2)
Subsets not equal.
ok 19 - Not expecting equal subsets.
- or download this
#!/usr/bin/env perl -l
...
@$array[@$array - $opt{array_limit} .. $#$array] )
: @$array);
}
- or download this
$ pm_split_equal_sums.pl --tm=1 --th=1 --vt=1 --vpm=5 --al=3
1..31
...
Subset sum = 1250025000
ok 31 - Expecting equal subsets.
Took 0.060788 seconds
- or download this
$ pm_split_equal_sums.pl --tm=0 --th=1 --vt=1 --vpm=5 --al=3
Checking: (1, 6, 2)
...
and (1, 1, 2, ... [snip: 99994 elements] ..., 49999, 50000,
+50000)
Subset sum = 1250025000
Took 0.060971 seconds
- or download this
#!/usr/bin/env perl -l
...
@$array[@$array - $opt{array_limit} .. $#$array] )
: @$array);
}
- or download this
$ pm_split_equal_sums.pl --tm=1 --th=1 --vt=1 --vpm=8 --al=3
1..41
...
Subset sum = 35184376283136
ok 41 - Expecting equal subsets.
Took 89.489836 seconds