September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,34 +1,34 @@
/*REXX pgm generates a self-referential sequence and lists the maximums.*/
parse arg low high .; maxL=0; seeds=; max$$=
if low=='' then low=1 /*no low? Then use the default*/
if high=='' then high=1000000 /* " high? " " " " */
/*══════════════════════════════════════════════════traipse through #'s.*/
do seed=low to high; n=seed; $.=0; $$=n; $.n=1
/*REXX program generates a self─referential sequence and displays the maximums. */
parse arg LO HI . /*obtain optional arguments from the CL*/
if LO=='' | LO=="," then LO= 1 /*Not specified? Then use the default.*/
if HI=='' | HI=="," then HI=1000000 - 1 /* " " " " " " */
max$=; seeds=; maxL=0 /*inialize some defaults and counters. */
do j=1 until x==n /*generate a self─referential seq*/
x=n; n=
do k=9 by -1 for 10 /*gen new sequence*/
_=countstr(k,x); if _\==0 then n=n||_||k
end /*k*/
if $.n then leave /*sequence been generated before?*/
$$=$$'-'n; $.n=1 /*add number to sequence & roster*/
end /*j*/
do #=LO to HI; n=#; @.=0; @.#=1 /*loop thru seed; define some defaults.*/
$=n
do c=1 until x==n; x=n /*generate a self─referential sequence.*/
n=; do k=9 by -1 for 10 /*generate a new sequence (downwards). */
_=countstr(k, x) /*obtain the number of sequence counts.*/
if _\==0 then n=n || _ || k /*is count > zero? Then append it to N*/
end /*k*/
if @.n then leave /*has sequence been generated before ? */
$=$'-'n; @.n=1 /*add the number to sequence and roster*/
end /*c*/
if j==maxL then do /*sequence equal to max so far ? */
seeds=seeds seed; maxnums=maxnums n; max$$=max$$ $$
if c==maxL then do; seeds=seeds # /*is the sequence equal to max so far ?*/
max$=max$ $ /*append this self─referential # to $ */
end
else if j>maxL then do /*have found a new best sequence.*/
seeds=seed; maxL=j; maxnums=n; max$$=$$
end
end /*seed*/
/*═══════════════════════════════════════════════════display the output.*/
say 'seeds that had the most iterations =' seeds
hdr=copies('',30); say 'maximum sequence length =' maxL
else if c>maxL then do; seeds=# /*use the new number as the new seed. */
maxL=c; max$=$ /*also, set the new maximum L; max seq.*/
end /* [↑] have we found a new best seq ? */
end /*#*/
do j=1 for words(max$$); say
say hdr "iteration sequence for: " word(seeds,j) ' ('maxL "iterations)"
q=translate(word(max$$,j),,'-')
do k=1 for words(q); say word(q,k)
say ' seeds that had the most iterations: ' seeds
say 'the maximum selfreferential length: ' maxL
do j=1 for words(max$) ; say
say copies('',30) "iteration sequence for: " word(seeds,j) ' ('maxL "iterations)"
q=translate( word( max$, j), ,'-')
do k=1 for words(q); say word(q, k)
end /*k*/
end /*j*/
/*stick a fork in it, we're done.*/
end /*j*/ /*stick a fork in it, we're all done. */