all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,25 @@
function stooge(sequence s, integer i, integer j)
object temp
integer t
if compare(s[j], s[i]) < 0 then
temp = s[i]
s[i] = s[j]
s[j] = temp
end if
if j - i > 1 then
t = floor((j - i + 1)/3)
s = stooge(s, i , j-t)
s = stooge(s, i+t, j )
s = stooge(s, i , j-t)
end if
return s
end function
function stoogesort(sequence s)
return stooge(s,1,length(s))
end function
constant s = rand(repeat(1000,10))
? s
? stoogesort(s)