Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,14 +1,14 @@
/*REXX program finds the shortest greatest continuous subsequence sum.*/
parse arg @; w=words(@) /*get arg list; # words in list.*/
say 'words='w " list="@ /*show #words & LIST to console.*/
sum=0; L=0; at=w+1 /*default sum, length, starts at.*/
/* [↓] process the list of nums.*/
do j=1 for w; f=word(@,j) /*select one number at a time. */
do k=j to w /* [↓] process a sub─list of #s.*/
s=f; do m=j+1 to k; s=s+word(@,m); end /*m*/
/*REXX program finds the shortest greatest continuous subsequence sum. */
parse arg @; w=words(@) /*get arg list; number words in list. */
say 'words='w " list="@ /*show number words & LIST to terminal,*/
sum=0; L=0; at=w+1 /*default sum, length, and "starts at".*/
/* [↓] process the list of numbers. */
do j=1 for w; f=word(@,j) /*select one number at a time from list*/
do k=j to w; s=f /* [↓] process a sub─list of numbers. */
do m=j+1 to k; s=s+word(@,m); end /*m*/
if s>sum then do; sum=s; at=j; L=k-j+1; end
end /*k*/ /* [↑] chose greatest sum of #s.*/
end /*k*/ /* [↑] chose greatest sum of numbers. */
end /*j*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize it.*/
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're done.*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null. */
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're all done. */

View file

@ -1,14 +1,14 @@
/*REXX program finds the longest greatest continuous subsequence sum.*/
parse arg @; w=words(@) /*get arg list; # words in list.*/
say 'words='w " list="@ /*show #words & LIST to console.*/
sum=0; L=0; at=w+1 /*default sum, length, starts at.*/
/* [↓] process the list of nums.*/
do j=1 for w; f=word(@,j) /*select one number at a time. */
do k=j to w; _=k-j+1 /* [↓] process a sub─list of #s.*/
s=f; do m=j+1 to k; s=s+word(@,m); end /*m*/
/*REXX program finds the longest greatest continuous subsequence sum. */
parse arg @; w=words(@) /*get arg list; number words in list. */
say 'words='w " list="@ /*show number words & LIST to terminal,*/
sum=0; L=0; at=w+1 /*default sum, length, and "starts at".*/
/* [↓] process the list of numbers. */
do j=1 for w; f=word(@,j) /*select one number at a time from list*/
do k=j to w; _=k-j+1; s=f /* [↓] process a sub─list of numbers. */
do m=j+1 to k; s=s+word(@,m); end /*m*/
if (s==sum & _>L) | s>sum then do; sum=s; at=j; L=_; end
end /*k*/ /* [↑] chose longest greatest sum*/
end /*k*/ /* [↑] chose the longest greatest sum.*/
end /*j*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize it.*/
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're done.*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null. */
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're all done. */