Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
function flip(sequence s, integer n)
|
||||
for i=1 to floor(n/2) do
|
||||
{s[i],s[n-i+1]} = {s[n-i+1],s[i]}
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
function pancake_sort(sequence s)
|
||||
integer m
|
||||
for i=length(s) to 2 by -1 do
|
||||
m = 1
|
||||
for j=2 to i do
|
||||
if s[j]>s[m] then
|
||||
m = j
|
||||
end if
|
||||
end for
|
||||
if m<i then
|
||||
if m>1 then
|
||||
s = flip(s,m)
|
||||
end if
|
||||
s = flip(s,i)
|
||||
end if
|
||||
end for
|
||||
return s
|
||||
end function
|
||||
|
||||
constant s = shuffle(tagset(10))
|
||||
? s
|
||||
? pancake_sort(s)
|
||||
Loading…
Add table
Add a link
Reference in a new issue