2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,14 +1,14 @@
/*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 numbers. */
end /*j*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null. */
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're all done. */
/*REXX program finds and displays 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; at=w+1 /*default sum, length, and "starts at".*/
L=0 /* [↓] 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 numbers. */
end /*j*/
say
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null (value). */
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; 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 the longest greatest sum.*/
end /*j*/
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null. */
say; say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're all done. */
/*REXX program finds and displays 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; at=w+1 /*default sum, length, and "starts at".*/
L=0 /* [↓] 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 the longest greatest sum.*/
end /*j*/
say
$=subword(@,at,L); if $=='' then $="[NULL]" /*Englishize the null (value). */
say 'sum='sum/1 " sequence="$ /*stick a fork in it, we're all done. */