Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

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

View file

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

View file

@ -0,0 +1,31 @@
/* REXX ***************************************************************
* 09.08.2012 Walter Pachl translated Pascal algorithm to Rexx
**********************************************************************/
s=' -1 -2 3 5 6 -2 -1 4 -4 2 -1'
maxSum = 0
seqStart = 0
seqEnd = -1
do i = 1 To words(s)
seqSum = 0
Do j = i to words(s)
seqSum = seqSum + word(s,j)
if seqSum > maxSum then Do
maxSum = seqSum
seqStart = i
seqEnd = j
end
end
end
Say 'Sequence:'
Say s
Say 'Subsequence with greatest sum: '
If seqend<seqstart Then
Say 'empty'
Else Do
ol=copies(' ',seqStart-1)
Do i = seqStart to seqEnd
ol=ol||right(word(s,i),3)
End
Say ol
Say 'Sum:' maxSum
End