Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,31 @@
/*REXX program performs a type of bogo sort on numbers in an array. */
parse arg list /*obtain optional list from C.L. */
if list='' then list=-21 333 0 444.4 /*Not defined? Then use default.*/
#=words(list) /*the number of numbers in list. */
do i=1 for words(list); @.i=word(list,i); end /*create an array.*/
call tell 'before bogo sort'
do bogo=1
do j=1 for #-1; jp=j+1 /* [↓] compare a # with the next*/
if @.jp>=@.j then iterate /*so far, so good; keep looking.*/
/*get 2 unique random #s for swap*/
do until a\==b; a=random(1, #); b=random(1, #); end
parse value @.a @.b with @.b @.a /*swap 2 random numbers in array.*/
iterate bogo /*go and try another bogo sort. */
end /*j*/
leave /*we're finished with bogo sort. */
end /*bogo*/ /* [↓] show the # of bogo sorts.*/
say 'number of bogo sorts performed =' bogo
call tell ' after bogo sort'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: say; say center(arg(1), 50, '')
do t=1 for #
say arg(1) 'element'right(t, length(#))'='right(@.t, 18)
end /*t*/
say
return

View file

@ -0,0 +1,42 @@
/*REXX program performs a type of bogo sort on numbers in an array. */
@.1 = 0 ; @.11= -64 ; @.21= 4096 ; @.31= 6291456
@.2 = 0 ; @.12= 64 ; @.22= 40960 ; @.32= 5242880
@.3 = 1 ; @.13= 256 ; @.23= 16384 ; @.33= -15728640
@.4 = 2 ; @.14= 0 ; @.24= -114688 ; @.34= -27262976
@.5 = 0 ; @.15= -768 ; @.25= -131072 ; @.35= 29360128
@.6 = -4 ; @.16= -512 ; @.26= 262144 ; @.36= 104857600
@.7 = 0 ; @.17= 2048 ; @.27= 589824 ; @.37= -16777216
@.8 = 16 ; @.18= 3072 ; @.28= -393216 ; @.38= -335544320
@.9 = 16 ; @.19= -4096 ; @.29= -2097152 ; @.39= -184549376
@.10= -32 ; @.20= -12288 ; @.30= -262144 ; @.40= 905969664
/* [↑] @.1 is really the 0th Berstel number*/
#=40 /*we have a list of two score Berstel numbers.*/
call tell 'before bogo sort'
do bogo=1
do j=1 for #; ?=@.j /*? is the next number in array.*/
do k=j+1 to #
if @.k>=? then iterate /*is this # in order? Get next. */
/*get 2 unique random #s for swap*/
do until a\==b; a=random(j, k); b=random(j, k); end
parse value @.a @.b with @.b @.a /*swap 2 random #s in array.*/
iterate bogo /*go and try another bogo sort. */
end /*k*/
end /*j*/
leave /*we're finished with bogo sort. */
end /*bogo*/ /* [↓] show the # of bogo sorts.*/
say 'number of bogo sorts performed =' bogo
call tell ' after bogo sort'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: say; say center(arg(1), 50, '')
do t=1 for #
say arg(1) 'element'right(t, length(#))'='right(@.t, 18)
end /*t*/
say
return

View file

@ -1,46 +0,0 @@
/*REXX program;to perform a type of bogo sort on an array. */
/*a.1 is really the 0th Berstel number... */
a.1 = 0 ; a.11= -64 ; a.21= 4096 ; a.31= 6291456
a.2 = 0 ; a.12= 64 ; a.22= 40960 ; a.32= 5242880
a.3 = 1 ; a.13= 256 ; a.23= 16384 ; a.33= -15728640
a.4 = 2 ; a.14= 0 ; a.24= -114688 ; a.34= -27262976
a.5 = 0 ; a.15= -768 ; a.25= -131072 ; a.35= 29360128
a.6 = -4 ; a.16= -512 ; a.26= 262144 ; a.36= 104857600
a.7 = 0 ; a.17= 2048 ; a.27= 589824 ; a.37= -16777216
a.8 = 16 ; a.18= 3072 ; a.28= -393216 ; a.38= -335544320
a.9 = 16 ; a.19= -4096 ; a.29= -2097152 ; a.39= -184549376
a.10= -32 ; a.20= -12288 ; a.30= -262144 ; a.40= 905969664
size=40 /*we have a list of two score Berstel numbers.*/
call tell 'un-bogoed'
do bogo=1
do j=1 for size
_=a.j
do k=j+1 to size
if a.k>=_ then iterate
n=random(j,k) /*we have an num out of order.get rand*/
do forever; m=random(j,k) /*get another random number.*/
if m\==n then leave /*ensure we're not swapping the same #*/
end /*forever*/
parse value a.n a.m with a.m a.n /*swap 2 random nums*/
iterate bogo
end /*k*/
end /*j*/
leave
end /*bogo*/
say 'number of bogo sorts performed =' bogo-1
call tell ' bogoed'
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: say; say center(arg(1),40,'')
do j=1 to size
say arg(1) 'element'right(j,length(size))'='right(a.j,20)
end /*j*/
say
return