Subset sum problem: Difference between revisions

m
→‎version 2: optimized y-1 expression into ym. -- ~~~~
(→‎version 2: approximated the version 2 's speed vs. version 1. -- ~~~~)
m (→‎version 2: optimized y-1 expression into ym. -- ~~~~)
Line 851:
do j=1; L=!.d; do d=2 for ym; L=L !.d; end /*d*/
_=!.1; s=#._
do k=2 for y-1ym until s>target; _=!.k; s=s+#._; end /*sum weights.*/
if s==target then call telly
!.y=!.y+1; if !.y==base then if .combUp(ym) then leave