Subset sum problem: Difference between revisions
Content added Content deleted
(→{{header|Python}}: Brute force it) |
(→version 2: approximated the version 2 's speed vs. version 1. -- ~~~~) |
||
Line 774: | Line 774: | ||
<br>Code could've been included to sort the table, but the extra code would've made the |
<br>Code could've been included to sort the table, but the extra code would've made the |
||
<br>program more bulkier, so the list was just sorted externally. |
<br>program more bulkier, so the list was just sorted externally. |
||
<br>It's faster than version 1 (above) because it takes advantage of short-circuiting the |
<br>It's about three times faster than version 1 (above) because it takes advantage of short-circuiting the |
||
<br>summing process, this version isn't a brute-force method. |
<br>summing process, this version isn't a brute-force method. |
||
<lang rexx>/*REXX pgm finds some non-null subsets of a weighted list whose sum=0. */ |
<lang rexx>/*REXX pgm finds some non-null subsets of a weighted list whose sum=0. */ |